Logo
banner

Blogs

Hide a field in all the stages of a Business Process Flow in Dynamics 365

, December 8, 2017 2180 Views

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

mm

Inkey

INKEY is your solution partner.
Our focus is to deliver you in-time intelligent innovative solutions ("key") for the problems in hand. Maintaining a quality standard right from the inception of a project is our top most priority.

Our team of talented professionals will execute your projects with dedication and excellence. We take ownership and accountability for the effort that goes into meeting our client’s needs.

Years of experience and proven success of delivering innovative custom solutions.

More posts by

6 responses to “Hide a field in all the stages of a Business Process Flow in Dynamics 365”

  1. Ben says:

    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?

    • Ancy John says:

      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.

  2. Ibrahim abo sabaa says:

    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);
    }
    }
    );

    • Ancy John says:

      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);
      }
      });

Leave a Reply

Your email address will not be published. Required fields are marked *