Microsoft Dynamics CRM

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!

Advertisements

20 thoughts on “Scripting tit-bits for Business Process stage field: Dynamics CRM 2013 Javascript”

  1. Please help me I am trying to disable the field on the Business Process Flow. But its not working. Below is line of code which I am applying. My Field name is “realest_mousignedbycustomer”.

    Xrm.Page.getControl(“header_process_realest_mousignedbycustomer”).setDisabled(true);

    Is this right syntax which I am applying. Need Urgent Help

    Thanks In Advance.

    Noman Mansoor

    1. This script will only work for the field if current selected stage or visible stage on the form is selected contains the field, for other cases it will not work. I will update you for other cases.

      1. I tried its work. But as you said Stage should have to visible. If we are moving back and forth in between the stages then it will destroy whole my business process. My scenario is once user checked then system have to disable it.
        New features are killing me :).
        Thank you a lot. Can I bother you some other points I am struggling in 2013 🙂

        Noman Mansoor

  2. Yes, sure and if stage is not visible try this: Xrm.Page.getControl(“header_process_realest_mousignedbycustomer”).set_disabled(true);
    Let me know your questions, happy to help and learn.. 🙂

  3. Hello – deepeshsomani2013
    I’ve tried to do your script with hidden stage, but it doesn’t work for me…
    What I wrote:
    function processflow() { Xrm.Page.getControl(‘header_process_ods_date_start_fact’).set_disabled(true);
    };

    something wrong?
    thx

  4. Hi,

    I have myself a problem with the business process.
    I need somehow to trigger an “onchange” event when process changes. Basically I need to attach an event to a process field (this I’m doing it at page on load) but if we’re in a stage where the process field is not visible, I cannot attach any process. Have any idea?

    Thanks!

    1. Hi,

      Put a synchronous workflow and update a hidden field on form on change of process id,You can locate Process(Processid) when record fields change, update a hidden optionset
      Attach your script to this optionset.Hope it helps!

  5. This can be done out of the box without scripting.

    – Create new field and add it to the Process Flow
    – Set the field with Field Level Security
    – Create a Field Level Security Profile for All Users with Read Access
    – Have a workflow update the field based on another action (such as another field update or user action)
    – Set the workflow on Run As Workflow Owner
    – Assign the Workflow to an Administrator

    Now the field is disabled in the Process Bar, but it also stays disabled if you promote to another phase in the Process. If you navigate back to the phase the field is in, it is still disabled.

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