Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

persistProperties not storing data

I have created a custom visual, but I want to store some settings with a larger string value or let the user present a better interface for it.

I have created a 'edit screen' to modify my parameters, not fancy at the moment but it does give me an interface.

 

Within my capabilities I have create my properties

 

"objects": {
        "dataPoint": {
            "displayName": "General",
            "displayNameKey": "GeneralSettings",
            "properties": {
                "formatString": {
                    "type": { "formatting": { "labelDisplayUnits": false } }
                },                
                "css": {
                    "displayName": "CSS",
                    "type": {
                        "text": true
                    }
                },
                "templateHeader": {
                    "displayName": "Header",
                    "type": {
                        "text": true
                    }
                },
                "templateItem": {
                    "displayName": "Item",
                    "type": {
                        "text": true
                    }
                },
                "templateFooter": {
                    "displayName": "Footer",
                    "type": {
                        "text": true
                    }
                }
            }
        }
    },

Within the visual.ts I have hide these properties

public enumerateObjectInstances(options: EnumerateVisualObjectInstancesOptions): VisualObjectInstance[] | VisualObjectInstanceEnumerationObject {
        const instanceEnumeration: powerbi.VisualObjectInstanceEnumeration = VisualSettings.enumerateObjectInstances(this.settings || VisualSettings.getDefault(), options);

        switch (options.objectName) {
            case "general" :
                // ignore rendering general settings ( it include only hidden properties )
                return;
        }
        return instanceEnumeration;
    }

And when I press the save button on my custom button my function does execute

private persist() {
        let objects: powerbi.VisualObjectInstancesToPersist = {
            merge: [
                <VisualObjectInstance>{
                    objectName: "general",
                    selector: undefined,
                    properties: {
                        "css" : __this.config_CSS.value,
                        "templateHeader" : __this.config_TemplateHeader.value,
                        "templateItem" : __this.config_TemplateItem.value,
                        "templateFooter" : __this.config_TemplateFooter.value,
                    }
                }]
        };
        
        this.host.persistProperties(objects);
    }

The debugger of the object does give me a correct object that I give to the persistProperties function

{"merge":[{"objectName":"general","properties":{"css":"test","templateHeader":"h","templateItem":"i","templateFooter":"f"}}]}

The console does not give me any errors that something went wrong, but after closing the editor my properties remain empty.

 

What I notice is that when I open the dataviewer console the 'metadata' property only contains 'columns' and no 'properties'. I have seen this within other example around the internet

 

What am I doing wrong?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Found it! (It helps to write it down)

 

In my capabilities I called the group 'dataPoint', but was referring to 'general' within the code...

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Found it! (It helps to write it down)

 

In my capabilities I called the group 'dataPoint', but was referring to 'general' within the code...

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.