How to use parent.Xrm.WebAPI in standalone web resources (not in CRM form)
Are you working with CRM on-premises and developing a standalone web resources without CRM form ? You can face with this trouble and this article is for you.
What is the issue?
Basically, we need to include a reference to ClientGlobalContext.js.aspx to HTML web resources but it does not make the Xrm object available. Therefore, scripts containing Xrm.* methods aren't supported in HTML web resources. And the scripts containing parent.Xrm.* will work if the HTML web resources is loaded in a form container. However, for other places, such as loading an HTML standalone web resources, parent.Xrm.* also won't work. If you try to use it on standalone web resources in on-premise environment version 9.1 (or 9.0), you will receive the error:
Root cause
After a lot of time to debug this error, I found it come from the Xrm.WebApi method. It is failing on a line where it attempts to take the entityname and resolve it to the setname (plural). It does this by comparing the value passed into the retrieveMultipleRecords method and comparing it to a global variable ENTITY_SET_NAMES.
This variable is unfortunately not present and parent.Xrm.WebApi throws an error.
Workaround
However, the standalone web resources is needed in some scenarios with specific business which we must accept the unsupported way to leverage the advantages of its and we could do a "magic" to use parent.Xrm.* into the standalone web resources.
Note: Please be aware that: This is the unsupported method.
First of all, we need to identify how many entities we work with parent.Xrm.WebApi in the web resource.
And those entities are not present in global variable ENTITY_SET_NAMES. So we create it.
In the window variable, we create an attribute ENTITY_SET_NAMES is a JSON-parsable string which contains the logical name and set a name for each entity.
Finally, we need execute that function before any calls to parent.Xrm.WebApi methods appears to work.
Some final words
Now, your issue should be resolved. Hope that Microsoft will fix it soon and the article will become a good resource for you.
If you have any better solutions or any questions, feel free to comment below. Your opinions are appreciated.
Published on:
Learn moreRelated posts
AI Agents in Microsoft Power Platform: Where Custom Agentic CRM Fits in Dynamics 365 Customer Engagement
In many CRM planning conversations right now, AI agent discussions are starting before organizations have fully aligned governance, integratio...
Business Process Flows in Dynamics 365 CE
Let’s look back at an oldie but a goodie in Dynamics 365 CE/CRM: Business Process Flows! These are designed to standardize how records m...
20 Most Commonly Used JavaScript Scenarios with Sample Code Snippets in Form Script – Dataverse / Dynamics 365 CE
JavaScript plays a critical role in Microsoft Dataverse and Dynamics 365 Customer Engagement (CE) applications. While Power Automate and Busin...
Dynamics 365 CE and Power Platform Developer Syllabus
Extensive & Advanced Syllabus for Power Platform & Dynamics 365 CE If you want to become an expert in Microsoft Power Platform and Dyn...
From Campaign Automation to Agentic Marketing: The Next Phase of Microsoft Dynamics 365 Customer Engagement
As organizations evaluate Microsoft Dynamics 365 Customer Insights capabilities, a common question keeps emerging: Are we still designing camp...
Dynamics 365 CE 2026 Release Wave 1 Launch Event Webinar
Western Computer recently hosted a launch event walking through Dynamics 365 CE 2026 Release Wave 1, focused on what's changing across Sales, ...
Microsoft Copilot in Dynamics 365 Customer Engagement: Where Teams See the Most Value
Artificial intelligence, particularly Microsoft Copilot in Dynamics 365 Customer Engagement, is quickly becoming part of everyday work across ...
Microsoft Power Platform 2026 Release Wave 1: What Copilot and Agents Mean for Dynamics 365 Customer Engagement
In conversations with organizations over the past several months, a consistent question has started to surface: how do we actually use these A...
Azure Data Factory Tips for Reliable Microsoft Dynamics 365 CE and Dataverse Integrations
Reliable integrations between Microsoft Dynamics 365 Customer Engagement and external systems can become challenging. This is especially true ...