In this article, I'll talk about opening web resources using the Xrm.Utility.openWebResource function.
Xrm.Utility.openWebResource(webResourceName,webResourceData,width, height)
The new function opens a new web resource by passing its schema name, optional data, width and height.
Assume you have a retail clothing company and agents receive calls from customers asking about clothing size. The company deals with international customers, which means agents have to convert from different sizes (UK, Euro or US).
With one click, agents can quickly revise the sizes by clicking on a ribbon button.
I placed a ribbon button and called it Clothing Sizes and when I click the ribbon button it invokes a Javascript function
mag.OpenConstants = function () {
Xrm.Utility.openWebResource("mag_constants.jpg");
}
This function opens a new window and loads a web resource of type jpg
Another example, you can call Xrm.Utility.openWebresource and pass a HTML web resource and data parameters like this
Xrm.Utility.openWebResource("new_webResource.htm?typename=account&userlcid=1033");
The HTML file can parse the parameters and consume it. For more information, see Sample: Pass multiple values to a web resource through the data parameter
Assume your organization faces clients every day. Part of the business process requires the client who visits your organization to physically view the Agent's Monitor. The agent shows the client some information before submitting or completing a stage in the business process. However, you would like the agent to share the values of a few fields on a form- say Contact entity- with fancy big fonts in a separate window.
I placed another Ribbon/Command button on the Contact form and called it Beautify Form
When clicked, it calls a JScript function
mag.beautifyForm = function () {
var customParameters = encodeURIComponent("firstname=Ahmed&company=Magnetism Solutions Ltd.&title=CRM Developer");
Xrm.Utility.openWebResource("mag_/FormattedForm.htm", customParameters);
}
In this example, I have hardcoded the data parameters, but in real life, you would read the values from fields on the form or elsewhere.
All parameters must be encoded before passing the parameters.
Here is the end result of a HTML page that parses the parameters.
Although the HTML does not look elegant, you can change or build your own style with logos and images to meet your taste.