Sunday, 12 April 2015

CRM 2015 - Javascript - Opening a Web Resource

 Javascript function from the Namespace Xrm.Utility that can be called to open a Web Resource with the possibility of adding parameters. Bare in mind that cannot that this function will not work with Microsoft Dynamics CRM for tablets.   

Xrm.Utility.openWebResource(webResourceName,webResourceData,width, height) 

Parameters 

  

Name Type Required Description 

webResourceName 

String 

Yes 

The name of the HTML web resource to open. 

webResourceData 

String 

No 

Data to be passed into the data parameter. 

width 

Number 

No 

The width of the window to open in pixels. 

height 

Number 

No 

The height of the window to open in pixels. 

Return Value 

Window object. 

Remarks 

An HTML web resource can accept the parameter values described in   Passing Parameters to HTML Web Resources . This function only provides for passing in the optional data parameter. To pass values for the other valid parameters, you must append them to the webResourceName   parameter. 

Examples 

Open an HTML web resource named “new_webResource.htm” 

Xrm.Utility.openWebResource( "new_webResource.htm" ); 

Open an HTML web resource including a single item of data for the data parameter 

Xrm.Utility.openWebResource( "new_webResource.htm" , "dataItemValue" ); 

Open an HTML web resource passing multiple values through the data parameter 

 var  customParameters = encodeURIComponent( "first=First Value&second=Second Value&third=Third Value" );Xrm.Utility.openWebResource( "new_webResource.htm" ,customParameters); 

noteNote 
These values have to be extracted from the value of the data parameter in the HTML web resource. For more information, see   Sample: Pass multiple values to a web resource through the data parameter 

Open an HTML web resource with the parameters expected by HTML web resources 

Xrm.Utility.openWebResource( "new_webResource.htm?typename=account&userlcid=1033" ); 

For more information, see   Passing Parameters to HTML Web Resources 

Open an HTML web resource, setting the height and width 

Xrm.Utility.openWebResource( "new_webResource.htm" , null , 300,300); 


From MSDN: https://msdn.microsoft.com/en-us/library/jj602956.aspx#BKMK_OpenWebResource 

Hope it helps.

No comments:

Post a Comment

CRM 365 Cloud - Disassociate 2 records using typescript

In case you need to Disassociate 2 records, please find below the code that allows you to do that.      export async function DissociateE...