Xrm.Utility.getResourceString in Dynamics 365. Which scenario it works and where it doesn’t? And what are the workarounds?

RESX web resources have been introduced for quite sometime but unfortunately even when I see project implementations today, I see constants file being used instead of Resource files. What more, you can even show specific values based on logged in user language. This blog post is not about how you can create a resource file and stuffs but more importantly using the Xrm.Utility.getResourceString method of WebApi both on your entity forms as well as webresources.


For the sake of completeness of this blog, let’s first create a resource file. Open any xml editor of your choice and let’s use the following resource content.

    <data name=”key1″>
       <value>Value 1</value>
    <data name=”key2″>
       <value>Value 2</value>

Let’s save the file with .resx extension.

Now let’s go ahead and create a webresource with the following content.

Webresource name – new_/strings/test.1033.resx

Type – Resource File (resx)

Observe the webresource name. I have included English language code (1033) in the file name.


Now let’s focus on the Xrm.Utility.getResourceString method.

1. Get Resource value on Entity Form

The first thing we will do is to use this method to get the resource value in entity form. For that we create a simple javascript webresource and add the resource file in the dependency list.


While this step is not mandatory, it is advised to do so. Adding the resource file in the dependency list will make sure you don’t get any reference errors while accessing resource file.

Now when you try to access the resource value based on the key, the appropriate value is received depending on the user’s language.


As you can see from the above screenshot, check for how I have used the resource file name. If the user language is English, it shall search for the file  ending with extension .1033.resx. If not matching file is found, it shall default to the generic file. That’s why it is always suggested to create generic resource file without any language code being mentioned in the file as fallback.


2. Get Resource Value on HTML webresource embedded in Entity Form

Now the next step is to access Resource file from HTML webresource embedded in entity form. It’s quite easy. Include ClientGlobalcontext.js.aspx with appropriate path in the HTML file and then use the resource file in dependency area of HTML web resource.

And the same code above shall work.

3. Get Resource Value on HTML webresource in separate window

Now let’s say you want to open a webresource in a separate window using Xrm.Navigation.openForm. And you follow the same steps as mentioned earlier. However this time, you will get an error while trying to access Xrm.Utility.getResourceString. Fortunately I came across Andew’s blog which helped me to resolve the issue. You can follow it here.


Hope this helps!

Debajit Dutta

(Dynamics MVP)

For consultation/ corporate training visit www.xrmforyou.com or reach out to us at info@xrmforyou.com

Our product offerings:

CRM-Sharepoint Attachment uploader and metadata manager (http://www.xrmforyou.com/sharepoint-integrator.html)

Notes Manager (https://debajmecrm.com/2019/02/28/add-metadata-to-your-notes-and-attachments-in-dynamics-notes-metadata-manager-from-xrmforyou-com/)

Role based views for Dynamics 365 (http://www.xrmforyou.com/role-based-views.html)

Record Cloner for Dynamics 365 (http://www.xrmforyou.com/record-cloner.html)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s