[Quick Tip] How to Apply Javascript On Business Process Fields

In Dynamics CRM 2013 having control on Business Process fields seems to be impossible. You cannot apply Business Rules on these fields but yet it’s possible to access them via Javascript. I think this can be very useful since it’s very simple to implement. You only have to prefix your field names in the code by header_process_ and let the script execute onLoad and onSave.

For example:

  • Getting field’s control when it’s on the form : Xrm.Page.getControl(“fieldname”);
  • Getting field’s control when it’s on the business process: Xrm.Page.getControl(“header_process_fieldname”);

In the business process suppose you want to update the text field field2 when the value of the boolean field1 is Yes:

function iSaidYes()

{

//Check the control on the form

if (Xrm.Page.getControl(“header_process_field1”) != null && Xrm.Page.getControl(“header_process_field2”) != null ) {

if(Xrm.Page.getControl(“header_process_field1”).getAttribute().getValue()==1)

{

Xrm.Page.getControl(“header_process_field2”).getAttribute().setValue(“I said Yes”);

}

else

{
Xrm.Page.getControl(“header_process_field2”).getAttribute().setValue(“I said No”);

}

}

}

 

 

 

 

 

Advertisements

One thought on “[Quick Tip] How to Apply Javascript On Business Process Fields

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