Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
I think the issue is `Visual::update()` is not called (no console.log), so we never update the internal model, and thus enumerateObjectInstances writes back to the format panel `""`
Relevant snippets:
"dataRoles": [ ... ],
"drilldown": { ... },
"dataViewMappings": [ ... ],
"objects": {
"mySetting": {
"displayName": "My Settings",
"properties": {
"myUserName": {
"displayName": "Account",
"type": {
"text": true
}
},
...
"use strict"; import "core-js/stable"; import 'regenerator-runtime/runtime' import "./../style/visual.less"; import powerbi from "powerbi-visuals-api"; import VisualConstructorOptions = powerbi.extensibility.visual.VisualConstructorOptions; import VisualUpdateOptions = powerbi.extensibility.visual.VisualUpdateOptions; import IVisual = powerbi.extensibility.visual.IVisual; import EnumerateVisualObjectInstancesOptions = powerbi.EnumerateVisualObjectInstancesOptions; import VisualObjectInstance = powerbi.VisualObjectInstance; import DataView = powerbi.DataView; import VisualObjectInstanceEnumerationObject = powerbi.VisualObjectInstanceEnumerationObject; import { dataViewObjects } from "powerbi-visuals-utils-dataviewutils"; iexport class Visual implements IVisual { private visualSettings: VisualSettings; public update(options: VisualUpdateOptions) { this.visualSettings = VisualSettings.parse(options.dataViews[0]); config.UserName = this.visualSettings.mySetting.myUserName;
... } public enumerateObjectInstances(options: EnumerateVisualObjectInstancesOptions) { const settings: VisualSettings = this.visualSettings || VisualSettings.getDefault(); return VisualSettings.enumerateObjectInstances(settings, options); }
... } export class MySetting { public myUserName: string = "";
... } export class VisualSettings extends DataViewObjectsParser { public mySetting: MySetting = new MySetting(); }
package.json
"dependencies": { "@types/jquery": "^3.5.8", "jquery": "^3.6.0", "regenerator-runtime": "^0.13.9", "uuid": "^7.0.2" }, "devDependencies": { "@types/d3": "5.7.2", "d3": "5.12.0", "powerbi-visuals-api": "^4.0.0", "powerbi-visuals-tools": "^3.3.2", "powerbi-visuals-utils-dataviewutils": "^2.4.1", "powerbi-visuals-utils-formattingutils": "^4.7.1", "powerbi-visuals-utils-interactivityutils": "^5.7.1", "powerbi-visuals-utils-tooltiputils": "^2.5.2", "tslint": "^5.20.1", "tslint-microsoft-contrib": "^6.2.0" }
pbiviz.json:
..."apiVersion": "4.0.0",...
tsconfig.json:
"compilerOptions": { "allowJs": false, "emitDecoratorMetadata": true, "experimentalDecorators": true, "module": "es6", "target": "ES6", "sourceMap": true, "outDir": "./.tmp/build/", "moduleResolution": "node", "declaration": true },
Hi @lmeyerov,
Did dm-p 's suggestions help with your scenario? if that is the case, you can consider Kudo or accept his suggestions to help others who faced similar requirements.
If that also doesn't help, please share more detailed information to help us clarify your scenario to test.
How to Get Your Question Answered Quickly
Regards,
Xiaoxin Sheng
Next step of the saga:
- if a Report editor manually edits the Fields panel, that triggers `update()`
- ... and then Format `update()`s start working as well
This is not intuitive behavior so far
Hi @lmeyerov,
If a user updates properties or field/data mappings, this triggers the update() method as your visual potentially receives new data from the main window, so this is your entry point for managing such changes - read this page in the visuals documentation in order to understand what happens with events from users, the main window and your visual, and which methods are called (or how you need to invoke them).
When a user modifies a property, the update method will be called by the main window, so if changes are being reverted in the pane to a default value then this suggest it's not able to run to completion or there is an issue with property enumeration and Power BI is assigning the default value back.
It's not easy to tell from your code if/what this is, as you only provided partial segments of your methods - and from the first line of the update method you have posted, this would fail as I can't see config declared anywhere that's in scope - I'm sure this is not actually the case and you probably have more code to manage this.
Have you ruled out any potential errors in your code to begin with, i.e. even using a try...catch block around the update method's code and logging the output? If in doubt you can add a console.log as the very first statement in your update method (before the property enumeration) to confirm it's being fired by the main window when the property is edited - it should be, and from your snippet, this isn't here for me to verify, although you mention it in your original post.
If you can trap some more specific detail regarding error output then we can see where to go from here. Failing that, you may need to provide more of your current code; ideally a clonable repo so it's easier to check-out and reproduce locally.
Regards,
Daniel
Proud to be a Super User!
My course: Introduction to Developing Power BI Visuals
On how to ask a technical question, if you really want an answer (courtesy of SQLBI)
User | Count |
---|---|
14 | |
4 | |
2 | |
1 | |
1 |
User | Count |
---|---|
20 | |
3 | |
2 | |
2 | |
2 |