<?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: Custom Visual - TextInput in Visual Format Setting does not save value and reverts to default in Custom Visuals Development Discussion</title>
    <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-Visual-TextInput-in-Visual-Format-Setting-does-not-save/m-p/3211136#M7379</link>
    <description>&lt;P&gt;EXCELENT!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see where I was going wrong.&amp;nbsp; Thank you.&amp;nbsp; I DID read that the names in the capabilities file and the settings needed to match, but apparently I was lost in the weeds and missed the obvious.&lt;/P&gt;</description>
    <pubDate>Fri, 28 Apr 2023 12:17:07 GMT</pubDate>
    <dc:creator>WZorn</dc:creator>
    <dc:date>2023-04-28T12:17:07Z</dc:date>
    <item>
      <title>Custom Visual - TextInput in Visual Format Setting does not save value and reverts to default</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-Visual-TextInput-in-Visual-Format-Setting-does-not-save/m-p/3209832#M7376</link>
      <description>&lt;P&gt;Here's what happens:&lt;/P&gt;&lt;P&gt;When I go to Visualizations-&amp;gt;Format Visual-&amp;gt;Visual, I have a textbox with default text in it.&amp;nbsp; If I enter new text and hit enter, nothing happens.&amp;nbsp; As soon as I click outside of the textbox the default value returns.&amp;nbsp; Can anyone explain what's happening?&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="WZorn_0-1682614489763.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/907658i84E9606A299B026E/image-size/medium?v=v2&amp;amp;px=400" role="button" title="WZorn_0-1682614489763.png" alt="WZorn_0-1682614489763.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is what I think are the relevent sections of code:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From Capabilities.json&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;	"objects": {
        "redirectURL": {
            "displayName": "Redirect",
            "properties": {
                "value": {
                    "displayName": "Hyperlink",
                    "type": {
                        "text": true
                    }
                }
            }
        }
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From Settings.ts&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;class DataPointCardSettings extends FormattingSettingsCard {
    
    redirectURL = new formattingSettings.TextInput({
        "placeholder": "Hyperlink",
        "name": "Hyperlink",
        "value": "Enter URL Here"
    });

    name: string = "redirection";
    displayName: string = "Redirection";
    slices: Array&amp;lt;FormattingSettingsSlice&amp;gt; = [this.redirectURL];
}

export class VisualFormattingSettingsModel extends FormattingSettingsModel {
    // Create formatting settings model formatting cards
    dataPointCard = new DataPointCardSettings();
    cards = [this.dataPointCard];
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;From visual.ts&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;import { FormattingSettingsService } from "powerbi-visuals-utils-formattingmodel";
import { VisualFormattingSettingsModel } from "./settings";
...

export class Visual implements IVisual {
    private formattingSettings: VisualFormattingSettingsModel;
    private formattingSettingsService: FormattingSettingsService;
	...

    constructor(options: VisualConstructorOptions) {
        ...
		
        this.formattingSettingsService = new FormattingSettingsService();
		
		...
	}
		
	public update(options: VisualUpdateOptions) {
		this.formattingSettings = this.formattingSettingsService.populateFormattingSettingsModel(VisualFormattingSettingsModel, options.dataViews);
	}

	public getFormattingModel(): powerbi.visuals.FormattingModel {
        return this.formattingSettingsService.buildFormattingModel(this.formattingSettings);
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Apr 2023 16:55:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-Visual-TextInput-in-Visual-Format-Setting-does-not-save/m-p/3209832#M7376</guid>
      <dc:creator>WZorn</dc:creator>
      <dc:date>2023-04-27T16:55:03Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Visual - TextInput in Visual Format Setting does not save value and reverts to default</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-Visual-TextInput-in-Visual-Format-Setting-does-not-save/m-p/3210550#M7378</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.fabric.microsoft.com/t5/user/viewprofilepage/user-id/304461"&gt;@WZorn&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When setting up your &lt;FONT face="courier new,courier"&gt;VisualFormattingSettingsModel&lt;/FONT&gt;, your card name (class property) must match the value declared in your capabilities. In your example, the object name in &lt;FONT face="courier new,courier"&gt;capabilities.json&lt;/FONT&gt; is&amp;nbsp;&lt;FONT face="courier new,courier"&gt;redirectURL&lt;/FONT&gt;, and it's &lt;FONT face="courier new,courier"&gt;dataPointCard&lt;/FONT&gt; in your &lt;FONT face="courier new,courier"&gt;settings.ts&lt;/FONT&gt;. Power BI will not be able to reconcile them and as a result your propoerty won't know where to get stored in the data view.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's a mimimal "happy path" example:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="5"&gt;capabilities.json&lt;/FONT&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;{
    ...
    "objects": {
        "redirection": {
            "properties": {
                "redirectURL": {
                    "type": {
                        "text": true
                    }
                }
            }
        }
    },
    ...
}&lt;/LI-CODE&gt;
&lt;P&gt;Note that I've given the object a name of &lt;FONT face="courier new,courier"&gt;redirection&lt;/FONT&gt;, as this is my assumed purpose of that particular formatting menu. I've kept the property name as &lt;FONT face="courier new,courier"&gt;redirectURL&lt;/FONT&gt;, just to help make them distinct in the example code. You can call these whatever you like as long as your associated settings classes and properties match (see below)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="5"&gt;settings.ts -&amp;nbsp;RedirectionCardSettings class&lt;/FONT&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;class RedirectionCardSettings extends FormattingSettingsCard {
    redirectURL = new formattingSettings.TextInput({
        name: 'redirectURL',
        displayName: 'Redirect URL',
        placeholder: 'Enter URL',
        value: ''
    });

    name: string = 'redirection';
    displayName: string = 'Redirection Settings';
    slices: Array&amp;lt;FormattingSettingsSlice&amp;gt; = [this.redirectURL];
}&lt;/LI-CODE&gt;
&lt;P&gt;I've set up my class that will match the properties in my object from my capabilities. I've named this&amp;nbsp;&lt;FONT face="courier new,courier"&gt;RedirectionCardSettings&lt;/FONT&gt;, but again, it's not that important.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What is important is that the class property - &lt;FONT face="courier new,courier"&gt;redirectURL&lt;/FONT&gt; matches the name of the corresponding property declaration from &lt;FONT face="courier new,courier"&gt;capabilities.json&lt;/FONT&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="5"&gt;settings.ts -&amp;nbsp;&lt;SPAN&gt;VisualFormattingSettingsModel class&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;export class VisualFormattingSettingsModel extends FormattingSettingsModel {
    redirection = new RedirectionCardSettings();

    cards = [this.redirection];
}&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;All I've done here is ensure that my class property, redirection matches the corresponding object name from &lt;FONT face="courier new,courier"&gt;capabilities.json&lt;/FONT&gt;. This will allow Power BI to reconcile your code-based properties and values with those declared in the capabilities (as Power BI only accepts 'known' objects and properties in the data view, which are handled by the capabilities when the visual is loaded). You can add more class properties but if there is no corresponding capability for it, then it will not work as intended.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;FONT size="5"&gt;&lt;SPAN&gt;Testing in the visual&lt;/SPAN&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I now get my card and property as expected, e.g.:&lt;/SPAN&gt;&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-1682657309576.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/907862i3CE902007E172FFE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dmp_0-1682657309576.png" alt="dmp_0-1682657309576.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I can enter a test value and tab out, or press [Enter], 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-1682657449353.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/907863i40AA2F5376E55F44/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dmp_1-1682657449353.png" alt="dmp_1-1682657449353.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;And I can see this in my data view, 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-1682657502470.png" style="width: 400px;"&gt;&lt;img src="https://community.fabric.microsoft.com/t5/image/serverpage/image-id/907864iBA7047819EB0485F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="dmp_2-1682657502470.png" alt="dmp_2-1682657502470.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hopefully, that should be all you need. Good luck!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2023 04:53:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-Visual-TextInput-in-Visual-Format-Setting-does-not-save/m-p/3210550#M7378</guid>
      <dc:creator>dm-p</dc:creator>
      <dc:date>2023-04-28T04:53:30Z</dc:date>
    </item>
    <item>
      <title>Re: Custom Visual - TextInput in Visual Format Setting does not save value and reverts to default</title>
      <link>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-Visual-TextInput-in-Visual-Format-Setting-does-not-save/m-p/3211136#M7379</link>
      <description>&lt;P&gt;EXCELENT!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I see where I was going wrong.&amp;nbsp; Thank you.&amp;nbsp; I DID read that the names in the capabilities file and the settings needed to match, but apparently I was lost in the weeds and missed the obvious.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2023 12:17:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Custom-Visuals-Development/Custom-Visual-TextInput-in-Visual-Format-Setting-does-not-save/m-p/3211136#M7379</guid>
      <dc:creator>WZorn</dc:creator>
      <dc:date>2023-04-28T12:17:07Z</dc:date>
    </item>
  </channel>
</rss>

