Passing parameters to JavaScript Web Resource function in CRM 2011.

Passing parameters to JavaScript Web Resource function in CRM 2011

If you want to use Generic Code in Javascript which will be Reusable in diff web resources pass the attribute value as Parameter in Event Source as mentioned below.

 In the calling Function need to Mention the” ExecutionContext” along with the parameter.

If you are not mention then it reads the parameters as “OBJECT”

 Note: If you want to pass more than one value then separate the attribute values with Semicolons

 Sample Javascript Web Resource for Account entity to get value of Account Name:

On load Code:

 

function test(ExecutionContext,Name){

 var name = Xrm.Page.data.entity.attributes.get(Name).getValue();

 // Or you can fetch the value using the following Way

var valuFromContext = ExecutionContext.getEventSource().controls.get(Name).getAttribute().getValue();

 }

 In Onload Function call , follow the below image.

 Cheers,

Happy Coding

Advertisements

One thought on “Passing parameters to JavaScript Web Resource function in CRM 2011.

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 )

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s