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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

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
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.