<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Passing access_token to custom visual (dynamically) in Custom Visuals Development Discussion</title>
    <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Passing-access-token-to-custom-visual-dynamically/m-p/3981259#M9891</link>
    <description>&lt;P&gt;thanks - I can set it to a measure but how would do I the mapping?&lt;/P&gt;</description>
    <pubDate>Sat, 08 Jun 2024 11:28:20 GMT</pubDate>
    <dc:creator>pieduke88</dc:creator>
    <dc:date>2024-06-08T11:28:20Z</dc:date>
    <item>
      <title>Passing access_token to custom visual (dynamically)</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Passing-access-token-to-custom-visual-dynamically/m-p/3977692#M9869</link>
      <description>&lt;P&gt;trying to pass an access_token to my custom visual.&lt;/P&gt;&lt;P&gt;If I use capabilities and data mapping, I end up with a lot of values because I am also passing some objectids and statuses. The access token value get copied and passed for every objectid value.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there another way to pass a single value (the token) to the visual?&lt;/P&gt;&lt;P&gt;I've tried properties but with no luck as the token is dynamic so needs to be pass dynamically to the visual (it refreshes every hour)&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jun 2024 17:09:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Passing-access-token-to-custom-visual-dynamically/m-p/3977692#M9869</guid>
      <dc:creator>pieduke88</dc:creator>
      <dc:date>2024-06-06T17:09:00Z</dc:date>
    </item>
    <item>
      <title>Re: Passing access_token to custom visual (dynamically)</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Passing-access-token-to-custom-visual-dynamically/m-p/3978157#M9878</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/483292"&gt;@pieduke88&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Properties would be your only option for a scalar value. If this is data-bound (and it sounds like it is if it's in your dataset), can you make this a measure and specify that the property use &lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/visuals/conditional-format?tabs=getFormattingModel" target="_self"&gt;conditional formatting&lt;/A&gt;?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Outside of this, the only alternative would be to use the HTTP fetch API to poll/resync your token from within your visual (assuming that (a) it's an option, (b) you haven't tried this already, and (c) your endpoint allows access from null origin iframes).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2024 00:05:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Passing-access-token-to-custom-visual-dynamically/m-p/3978157#M9878</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2024-06-07T00:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: Passing access_token to custom visual (dynamically)</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Passing-access-token-to-custom-visual-dynamically/m-p/3981259#M9891</link>
      <description>&lt;P&gt;thanks - I can set it to a measure but how would do I the mapping?&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jun 2024 11:28:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Passing-access-token-to-custom-visual-dynamically/m-p/3981259#M9891</guid>
      <dc:creator>pieduke88</dc:creator>
      <dc:date>2024-06-08T11:28:20Z</dc:date>
    </item>
    <item>
      <title>Re: Passing access_token to custom visual (dynamically)</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Passing-access-token-to-custom-visual-dynamically/m-p/3981917#M9893</link>
      <description>&lt;P&gt;how would that work?&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jun 2024 12:41:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Passing-access-token-to-custom-visual-dynamically/m-p/3981917#M9893</guid>
      <dc:creator>pieduke88</dc:creator>
      <dc:date>2024-06-09T12:41:37Z</dc:date>
    </item>
    <item>
      <title>Re: Passing access_token to custom visual (dynamically)</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Passing-access-token-to-custom-visual-dynamically/m-p/3982138#M9894</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/483292"&gt;@pieduke88&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/developer/visuals/conditional-format?tabs=getFormattingModel" target="_self"&gt;The documentation shows you how to implement&lt;/A&gt;, but if you want a simple example using the simple template visual you get when using &lt;FONT face="courier new,courier"&gt;pbiviz new&lt;/FONT&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H1&gt;Add Property and Slice to Settings&lt;/H1&gt;
&lt;P&gt;First, we'll add a property called &lt;STRONG&gt;testToken&lt;/STRONG&gt; to &lt;FONT face="courier new,courier"&gt;capabilities.json&lt;/FONT&gt;:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;{
    ...
    "objects": {
        "dataPoint": {
            "properties": {
                ...
                "testToken": {
                    "type": {
                        "text": true
                    }
                }
            }
        }
    },
    ...
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In &lt;FONT face="courier new,courier"&gt;settings.ts&lt;/FONT&gt;, we'll first add our imports, e.g.:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;import powerbiVisualsApi from "powerbi-visuals-api";
import VisualEnumerationInstanceKinds = powerbiVisualsApi.VisualEnumerationInstanceKinds;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Add a new property to the &lt;FONT face="courier new,courier"&gt;DataPointCardSettings&lt;/FONT&gt; class, e.g.:&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;/**
 * Data Point Formatting Card
 */
class DataPointCardSettings extends FormattingSettingsCard {
  
  ...

  // Simple text input
  testToken = new formattingSettings.TextInput({
    name: "testToken",
    displayName: "Test Token",
    value: "",
    placeholder: "Enter or assign token",
    // conditional formatting specifier
    instanceKind: VisualEnumerationInstanceKinds.ConstantOrRule
  });

  name: string = "dataPoint";
  displayName: string = "Data colors";
  slices: Array&amp;lt;FormattingSettingsSlice&amp;gt; = [
    ... // existing slices
    this.testToken, // Ensure that new property is added to the card
  ];
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that the object for this property needs the include the &lt;FONT face="courier new,courier"&gt;instanceKind&lt;/FONT&gt; to tell Power BI that it is a conditional formatting property.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H1&gt;Verify Conditional Formatting is Available&lt;/H1&gt;
&lt;P&gt;Save all changes and ensuring that the visual is reloaded, check the formatting pane. You should now see the card with the conditional formatting option, e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dmp_0-1717969772851.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1113615i4E46DE634E167449/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dmp_0-1717969772851.png" alt="dmp_0-1717969772851.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Use the dialog to browse to and select a suitable text measure from your model and then click&amp;nbsp;&lt;STRONG&gt;OK&lt;/STRONG&gt;. Your property will update to show that a measure is now assigned, e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dmp_1-1717969973791.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1113616i303D7FF1B8957555/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dmp_1-1717969973791.png" alt="dmp_1-1717969973791.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;H1&gt;Accessing the Property&lt;/H1&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This can now be accessed from your settings, just like any other property. For example, I can add the following to my visual's update method after the settings have been processed:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;    console.log(
      "Token value:",
      this.formattingSettings.dataPointCard.testToken.value
    );&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I'll see this in my browser console, e.g.:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="dmp_2-1717970242875.png" style="width: 999px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/1113618i3C52D849B3BCF6E2/image-size/large?v=v2&amp;amp;px=999" role="button" title="dmp_2-1717970242875.png" alt="dmp_2-1717970242875.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;----&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hopefully this will help you get started. Good luck!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Sun, 09 Jun 2024 21:59:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Passing-access-token-to-custom-visual-dynamically/m-p/3982138#M9894</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2024-06-09T21:59:03Z</dc:date>
    </item>
  </channel>
</rss>

