Scripting tit-bits for Business Process stage field: Dynamics CRM 2013 Javascript

We were facing lot of issues in trying to show hide , set disabled / enable fields or nullify fields which were not present as fields on form in Dynamics CRM 2013 but just were accessible on business process stage on the form. Here are the ways to do the same i found:

Enable/Disable Business Process stage field:

Xrm.Page.getControl(‘header_process_fieldname’).setDisabled(false);  //Enabled

Xrm.Page.getControl(‘header_process_fieldname’).setDisabled(true);  //Disabled

Show/Hide Business Process stage field:

Xrm.Page.getControl(‘header_process_fieldname’).setVisible(true);  //Show

Xrm.Page.getControl(‘header_process_fieldname’).setDisabled(false);  //Hide

Get Value/ Set Value Business Process stage field:

Xrm.Page.getControl(‘header_process_fieldname’).getAttribute().setValue(value);  //Set Value

Xrm.Page.getControl(‘header_process_fieldname’).getAttribute().getValue();  //Get Value

Set and Remove Notification on Business Process stage field:

Xrm.Page.getControl(‘header_process_fieldname’).setNotification(“Notification message”);  //Set Notification message

Xrm.Page.getControl(‘header_process_fieldname’).clearNotification(); // Clear Notification message

Set Required levels on Business Process stage field:

(Xrm.Page.getControl(‘header_process_fieldname).getAttribute()).setRequiredLevel(‘required’); //Required level

(Xrm.Page.getControl(‘header_process_fieldname).getAttribute()).setRequiredLevel(‘none’); //none level

(Xrm.Page.getControl(‘header_process_fieldname).getAttribute()).setRequiredLevel(‘recommended’); //Recommended level

Note: I have noticed this code will work when current stage field in business process on form is visible on UI.

Hope it helps!

Advertisement