The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
I want to show version or displayName from pbiviz.json in my visual.
In small print just to make it easy for knowing which reports need new versions of my visual.
I can not find a method to access these values. Is there a way to do that?
Solved! Go to Solution.
Hi @Anonymous,
Add "resolveJsonModule": true to the compilerOptions in your tsconfig.json [documentation].
Add an import in the desired .ts file for your pbiviz.json. Assuming that you're using src/visual.ts, this would look something like the following:
import * as pbiviz from '../pbiviz.json';
You can now access the JSON from pbiviz.json as if it were an object, e.g.:
pbiviz.visual.displayName;
I'm using this in Deneb for a similar reason. You can see where I'm doing this here if you need it for reference.
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)
Hi @Anonymous,
Add "resolveJsonModule": true to the compilerOptions in your tsconfig.json [documentation].
Add an import in the desired .ts file for your pbiviz.json. Assuming that you're using src/visual.ts, this would look something like the following:
import * as pbiviz from '../pbiviz.json';
You can now access the JSON from pbiviz.json as if it were an object, e.g.:
pbiviz.visual.displayName;
I'm using this in Deneb for a similar reason. You can see where I'm doing this here if you need it for reference.
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)
Yes! 👍
As simple as that.
Thanks a lot.
Hi @Anonymous ,
I think you can try to change the GUID in custom visual json code.
{ "visual": { "name": "CustomVisual", // internal visual name (should not contain spaces) "displayName": "Custom Visual!", // visual name displayed to user (used in gallery) "guid": "PBI_CV_xxxxxxx", // a unique id for this visual MUST BE UNIQUE "visualClassName": "Custom" // the entry class for your visual. (By default Visual: visual.ts) "version": "1.0.0", // visual version. Should be semantic version (increment if you update the visual) "description": "", // description used in gallery "supportUrl": "", // url to where users can get support for this visual "gitHubUrl": "" // url to the source in github (if applicable) },
Here is a solved post with similar issue like yours. I hope it could help you solve your issue.
Best Regards,
Rico Zhou
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I have no idea how this should help solve my problem.
In my visual to access the metadata (contained in the pbiviz.json) and then display that in a label in the visual.
something like
var version = this.metadata.visual.version;
This is not the correct syntax, but I can not find any info whether this is possible or how to do it.
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
2 | |
1 | |
1 | |
1 |