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!
you might find this interesting
https://bpfhelper.codeplex.com/
Thanks for including the link..will help!
[…] Scripting tit-bits for Business Process stage field: Dynamics CRM 2013 Javascript […]
[…] Scripting tit-bits for Business Process stage field: Dynamics CRM 2013 Javascript […]
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
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.
Please try the following : Xrm.Page.getControl(“header_process_realest_mousignedbycustomer”).set_disabled(true);
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
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.. 🙂
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
Hi Sergii,
It should work as expected. let me know if this control is used in more than one stage?
Regards,
Deepesh
Hi Sergii,
It should work as expected. Let me know if the field is placed in more than 1 stage?
Regards,
Deepesh
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!
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!
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.
Thanks Daniel, This is available for everyone to refer now. I had applied the approach in the blog during initial days of CRM 2013 and it did not used
to work then.
Good post, but I’m having trouble making it work. Are these methods still valid for CRM online 2015?
CRM 2015 has native support for business process in Xrm framework. Refer this link: https://dynamicsofdynamicscrm.wordpress.com/2014/10/29/scripting-tit-bits-coming-in-dynamics-crm-2015-business-process-flows/
hi all is there any way where i can hide or disbale the next and back button on Business Process Workflow
Unsupported, you can achieve so. In current version of CRM you can do it supported – CRM 2015 Update 1 and above.