cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
TheTruePowerDev
Frequent Visitor

using getResourceString to retieve resx file over an pcf-component

Hello,

is there a way to retrieve Resx-Webresources over PCF.
I've tried to achieve this via the "getResourceString"-methode over the XRM object.
I have also added the following feature-usage configuration:

<uses-feature name="Utility.getResourceString" required="true" />
... but even though the methode is available that also didn't help.
All i get is a not found error...

1 ACCEPTED SOLUTION

Accepted Solutions
DianaBirkelbach
Super User
Super User

Hi @TheTruePowerDev , 

 

The feature for Utility is called only "Utility". Here are the examples: https://learn.microsoft.com/en-us/power-apps/developer/component-framework/manifest-schema-reference...

If you do that, you get access to context.utils: https://learn.microsoft.com/en-us/power-apps/developer/component-framework/reference/context#utils, but you have only 3 methods there: getEntityMetadata, hasEntityPrivilege, lookupObjects: https://learn.microsoft.com/en-us/power-apps/developer/component-framework/reference/utility?WT.mc_i...

 

BUT, in PCF sdk there is a Resources namespace: https://learn.microsoft.com/en-us/power-apps/developer/component-framework/reference/resources?WT.mc...

You have there getResource and getString methods. This will work with the resources you've added to your PCF manifest, like resx, css,  images, and that's the supported way: https://learn.microsoft.com/en-us/power-apps/developer/component-framework/manifest-schema-reference...

 

So, for accessing resx packed inside your PCF, you can use these resources methods. The problem with that: you have to deliver the resx inside the PCF package. You can find more details about localizations for instance in Ivan's blog:  https://dynamicsninja.blog/2020/01/21/pcf-localization/

 

If you try to access resx WebResources that are not part of the PCF, you'll need some hacks.In my opinion that's not really supported.

Using the Xrm object inside the PCF is not supported.

You may try to access the WebResource address on your own, but I'm not sure if that will work in all cases/devices/apps.

You could try to build the url on your own, but you probably won't be able to access the cached version of the WebResource.

 

Hope this helps!

 

Kind regards,
Diana
----------
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

1 REPLY 1
DianaBirkelbach
Super User
Super User

Hi @TheTruePowerDev , 

 

The feature for Utility is called only "Utility". Here are the examples: https://learn.microsoft.com/en-us/power-apps/developer/component-framework/manifest-schema-reference...

If you do that, you get access to context.utils: https://learn.microsoft.com/en-us/power-apps/developer/component-framework/reference/context#utils, but you have only 3 methods there: getEntityMetadata, hasEntityPrivilege, lookupObjects: https://learn.microsoft.com/en-us/power-apps/developer/component-framework/reference/utility?WT.mc_i...

 

BUT, in PCF sdk there is a Resources namespace: https://learn.microsoft.com/en-us/power-apps/developer/component-framework/reference/resources?WT.mc...

You have there getResource and getString methods. This will work with the resources you've added to your PCF manifest, like resx, css,  images, and that's the supported way: https://learn.microsoft.com/en-us/power-apps/developer/component-framework/manifest-schema-reference...

 

So, for accessing resx packed inside your PCF, you can use these resources methods. The problem with that: you have to deliver the resx inside the PCF package. You can find more details about localizations for instance in Ivan's blog:  https://dynamicsninja.blog/2020/01/21/pcf-localization/

 

If you try to access resx WebResources that are not part of the PCF, you'll need some hacks.In my opinion that's not really supported.

Using the Xrm object inside the PCF is not supported.

You may try to access the WebResource address on your own, but I'm not sure if that will work in all cases/devices/apps.

You could try to build the url on your own, but you probably won't be able to access the cached version of the WebResource.

 

Hope this helps!

 

Kind regards,
Diana
----------
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Users online (2,624)