Operations in Business Process Flow using JavaScript in D365 CRM
Introduction – In this blog, you will learn about how we can perform different operations such as disable, enable, hide, etc. on D365 CRM Business Process flow using JavaScript.
Set value in Business Process Flow
var formContext = executionContext.getFormContext();
let bpfControl = formContext.getControl('header_process_cf_outreach')
let attribute = bpfControl.getAttribute();
if(attribute != undefined)
{
attribute.setValue(979570000);
}
Disable field on Business Process Flow
formContext.getControl("header_process_cf_outreach").setDisabled(true);
here cf_outreach is the schema name of the field on BPF. for BPF we need to write header_process before the schema name of the field
Enable field on Business Process Flow
formContext.getControl("header_process_cf_outreach").setDisabled(false);
Hide a field on Business Process Flow
formContext.getControl("header_process_cf_outreach").setVisible(false);
Mark Field Required on Business Process Flow
var formContext = executionContext.getFormContext();
let bpfControl = formContext.getControl('header_process_cf_outreach');
let attribute = bpfControl.getAttribute();
if(attribute != undefined)
{
attribute.setRequiredLevel("required");
}
Mark Field Optional on Business Process Flow
var formContext = executionContext.getFormContext();
let bpfControl = formContext.getControl('header_process_cf_outreach');
let attribute = bpfControl.getAttribute();
if(attribute != undefined)
{
attribute.setRequiredLevel("none");
}
Mark field recommended on Business Process Flow
var formContext = executionContext.getFormContext();
let bpfControl = formContext.getControl('header_process_cf_outreach');
let attribute = bpfControl.getAttribute();
if(attribute != undefined)
{
attribute.setRequiredLevel("recommended");
}