In a recent 8.2 version project, I struggled with a couple of requirements for a business process flow:
1) Making a stage-gate step required or not depending on other field values.
2) The field values involved were necessary in more than one phase of the process, but I didn't want them shown in the BPF ribbon.
For making a stage-gate step visible and required or not:
To make the attribute visible or not in the BPF, you need to affect the control.
To make an attribute required or not in the BPF, you need to affect the attribute.
For example, I am using the attribute called "new_verifiedapproval" that is a "Two Options" type field that is part of the BPF.
If in a certain situation, I want that field to appear as required in the BPF:
Xrm.Page.getControl("header_process_new_verifiedapproval").setVisible(true);
Xrm.Page.getAttribute("new_verifiedapproval").setRequiredLevel("required");
The 2nd line of code only works if the attribute is on the entity form.
If it already is, no worries.
If it isn't, then add it to your form, in a visible or non-visible state as appropriate to your needs. Since in my example the attribute serves only as a stage-gate, I don't want the user to interact with it anywhere else than in the BPF.
For affecting a BPF step tied to an attribute that is used more than once in the BPF:
Again, to make the attribute visible or not in the BPF, you need to affect the control.
Since the attribute is used more than once in the BPF, that means there are X controls in the BPF for the same attribute.
The first instance of the control will be called header_process_(attributename).
The second instance of the control will be called header_process_(attributename)_1.
The thrid instance of the control will be called header_process_(attributename)_2.
and so on.
So if your attribute is used as 3 distinct steps in your BPF for conditions but you want the attribute hidden from the BPF because it will be filled out in the entity form:
Xrm.Page.getControl("header_process_new_attribute").setVisible(false);
Xrm.Page.getControl("header_process_new_attribute_1").setVisible(false);
Xrm.Page.getControl("header_process_new_attribute_2").setVisible(false);
This was a tricky one since in the form, the rule for multiple instances of a same attribute is attributename, attributename1, attributename2, etc.
Go figure why the syntax is different for BPF controls.
Hope this helps!