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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
RobHofker
Frequent Visitor

Show version or displayName from pbiviz.json on visual

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?

1 ACCEPTED SOLUTION
dm-p
Super User
Super User

Hi @RobHofker,

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

 





Did I answer your question? Mark my post as a solution!

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)




View solution in original post

4 REPLIES 4
dm-p
Super User
Super User

Hi @RobHofker,

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

 





Did I answer your question? Mark my post as a solution!

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.

v-rzhou-msft
Community Support
Community Support

Hi @RobHofker ,

 

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.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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