Blog, CRM Extensions

How to use Xrm.Utility.getResourceString in Html WebResources

I saw several threads on community forums that state “Xrm.Utility.getResourceString” functionality doesn’t work in Html webresources. I decided to spend some time digging to find out why it doesn’t work and how to make it work.

During investigation I found out that Html window missed several objects that were available on regular entity form. Unfortunately I was not able to find easy way to create those object so I composed solution that composes and initiates all the required objects on the form. Here is what should be done to make “Xrm.Utility.getResourceString” work again:

  • add following code to your code before using “Xrm.Utility.getResourceString”. As a parameter for AB.HtmlLocalization.Initialize I pass an array of JavaScript that have “Resx” dependent webresources. It builds required structure of objects in window and returns promise.

This is the first release of the product and I haven’t done massive testing so if you found a bug or have suggestions feel free to leave your comment here or open an issue on the GitHub repository.


  1. Hi,

    I faced the same problem in CRM V9.0 and find that if you give the full name of the resource file, it returns the value. First, I add the Resource file as a dependency to the Html file. Then call the getResourceString method using the full name of the resource file.

    the full name of the resource file is: ab_/Messages.1033

    Working code:
    var userLCID = Xrm.Page.context.getUserLcid();
    var noDataMessage = Xrm.Utility.getResourceString(‘ab_/Messages.’ + userLCID, ‘LocalizedMessage’);

    Not Working Code:
    var noDataMessage = Xrm.Utility.getResourceString(‘ab_/Messages.’ + userLCID, ‘LocalizedMessage’);

    1. Sema,
      And you’re saying it will work in Html webresource without any additional injections?

  2. This solution doesn’t need additional JS/Plugin:

    return window.parent.Xrm.Utility.getResourceString(“xx_x”, messageKey);

    1. Hello Robert,
      Thanks for your comment! What is your scenario are you talking specifically? Did you do any additional configurations in order to make it work?

      1. Same scenario of HTM web resource in a Form accessing RESX content from the corresponding JS referenced in the HTM web resource. With ClientGlobalContext.js.aspx loaded, it only needs window.parent to access Xrm.Utility.getResourceString as long as the RESX files are configured as dependencies on the HTM web resource. Without window.parent it is not properly initialized in the current window as you found out.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.