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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Users online (3,104)