RE: Set field visibility on business process flow depending on field value.
Hi Tuomas,
You could do it by adding custom javascript at form onload event:
1. -> Below is general function, just replace field name to your own field name.
function hideSpecificFieldOnBpf() {
var selectedValue = (Xrm.Page.getAttribute("fieldname") != null) ? Xrm.Page.getAttribute("fieldname").getSelectedOption().text : "";
if (selectedValue == "Yes") {
Xrm.Page.getControl("header_process_fieldname").setVisible(false);
}
}
For example, I would like to hide Parent Contact field when lead type is Item based.

Code:
function hideSpecificFieldOnBpf() {
var selectedValue = (Xrm.Page.getAttribute("msdyn_ordertype") != null) ? Xrm.Page.getAttribute("msdyn_ordertype").getSelectedOption().text : "";
if (selectedValue == "Item based") {
Xrm.Page.getControl("header_process_parentcontactid").setVisible(false);
}
}
2. -> Be noticed that to grab field on BPF, the field name format should be header_process_fieldname.
You can find field logical name in entities customization:

Or check it in form editor directly.(because some fields have different form display/label name compared with real Display name)
You could download the extension to view fields logical name quickly
https://chrome.google.com/webstore/detail/level-up-for-dynamics-crm/bjnkkhimoaclnddigpphpgkfgeggokam

3. -> Finally, my code is based on old deprecated Xrm.Page, you could replace it to recommended executionContext:
function hideSpecificFieldOnBpf(executionContext) {
var formContext = executionContext.getFormContext();
var selectedValue = (formContext.getAttribute("fieldname") != null) ? formContext.getAttribute("fieldname").getSelectedOption().text : "";
if (selectedValue == "Yes") {
formContext.getControl("header_process_fieldname").setVisible(false);
}
}
Check the pass execution context .. option if you work with this.

Regards,
Clofly