I have come up with a solution to a problem that many of the CRM developers may have come across with. Let me explain the scenario as follows:
Suppose, you have created a Business Process Flow for an entity with multiple stages. And each stage is having a common field in it.
Now, the customer requires to hide that common field in all the stages once he reaches a particular stage.
Here I am explaining you the way, this requirement could be achieved:
When a form displays a business process flow control in the header, additional controls gets added for each attribute that is been displayed in that BPF.
These controls hold unique names like:-
header_process_<attribute name>
If you write:-
Xrm.Page.getControl(“header_process_<attribute name>”).setVisible(false)
It will just hide the first occurrence in BPF.
But, in our case we need to hide a particular field in all the BPF stages.
Thus we need to set visibility property to each of those fields as below:-
Xrm.Page.getControl(“header_process_<attribute name>”).setVisible(false) Xrm.Page.getControl("header_process_<attribute name>_1").setVisible (false); Xrm.Page.getControl("header_process_<attribute name>_2").setVisible (false); Xrm.Page.getControl("header_process_<attribute name>_3").setVisible (false);
(i.e) You just need to append numeric series to the attribute name based on the number of times a field occurs in BPF.
I Hope this helps you…
Happy CRMing!!
Insert data into Many-to-Many relationship in Dynamics CRM very easily & quickly, using the Drag and drop listbox.
http://www.inkeysolutions.com/what-we-do/dynamicscrmaddons/drag-and-drop-listbox
© All Rights Reserved. Inkey IT Solutions Pvt. Ltd. 2024
Great post, thank you for sharing this information Ancy!
Do you know how this would work with branching business process flows?
Is there a way to find out or export a list of all of the header attributes?
First of all, thank you so much for reading my post and giving such a valuable response as a comment. Now let me provide you my answers to the questions you asked in the comment.
Question: Is there a way to find out or export a list of all of the header attributes?
Suggested answer:
Please know, OOB in CRM, fields in the business process flow (BPF) are prefixed with the text “header_process_” and fields in the header of the entity form are prefixed with the text “header_”. Using UI, it seems difficult to get the list of the fields in the header or BPF but we can implement it using Xrm.Page model in Javascript. Please go to the link https://msdn.microsoft.com/en-in/library/dn817878.aspx#BKMK_Stage for functions provided by Microsoft to communicate with BPF’s in CRM.
Question: Do you know how this would work with branching business process flows?
Suggested answer: As per my understanding of the question, you need to access the fields in the new stage inserted based on the value of the field in the previous stage in a branched business process flow. If my understanding is correct, you can access them using Javascript as mentioned above. Else please share more details on this as I’m unable to understand your requirement.
Thanks for your reply Ancy! It sounds like to get all of the fields from the business process flow, one would need to run a loop and store them. Thanks again.
Yes.. You are right. We need to use loop for getting all the fields and store them, from business process flow.
Thanks for your post and your effort I’ve another idea might fit in this case
We can use the code below
Xrm.Page.getAttribute(attributeLogicalName).controls.forEach(
function (control) {
If(control.getName().indexOf(‘header_process_’)>-1){
control.setVisible(false);
}
}
);
Thank you for replying on this blog.
Sorry, but I do not understand, why did you execute loop on an attribute (i.e Xrm.Page.getAttribute(attributeLogicalName).controls.forEach).
We need to get all BPF controls. For that I think the code should be something like below:-
Xrm.Page.ui.controls.forEach(function (control)
{
If(control.getName().indexOf(‘header_process_’)>-1)
{
control.setVisible(false);
}
});