Showing posts with label Business Process Flow. Show all posts
Showing posts with label Business Process Flow. Show all posts

Thursday, 24 July 2014

Show and Hide Business Process Flow in CRM 2013/2015

Business Process Flow is a great feature in CRM 2013.

But, sometimes, in some conditions or simple situation, customer does not need this Business Process Flow, so we should hide it in certain conditions. You can enable or disable Business Process Flow by adjusting the security role, but, what if you want to hide the Business Process based on field value, form type, or selected form?

For example, I want to hide the Business Process Flow based on this field:

image

Once the ‘Show BPF’ field is checked, then I should Show the Business Process Flow, and vice versa, I should Hide it if this fields is unchecked.

*You can have your own scenario and certain condition, this is just one of the example.

So, here is the code:

function hideBusinessProcessFlow()
{
  document.getElementById('header_process_d').style.display = "none";
}

function showBusinessProcessFlow()
{
  document.getElementById('header_process_d').style.display = "block";
}

function showHideBusinessProcessFlow()
{
    if (Xrm.Page.getAttribute("new_showbpf").getValue() == true)
    {
        showBusinessProcessFlow();
    }
    else
    {
        hideBusinessProcessFlow();
    }
}

Then, as usual, register the showHideBusinessProcessFlow() function in the onChange Event Handler of the ‘Show BPF’ field.

And test the result:

*Checked

image

*Unchecked

image

NB: This is unsupported Customization, and you might be aware during the version upgrading I the future.

For your additional information, to switch or to change the Business Process Flow Process and Stage programmatically, you should refer to this great link:

http://develop1.net/public/post/How-to-change-process-and-stage-programmatically.aspx

[Updates for CRM 2015]

For those who are using CRM 2015, there is update in the Form Scripting to access the BPF Process.

Xrm.Page.ui.process

So, please use:

Xrm.Page.ui.process.setVisible(false); and Xrm.Page.ui.process.setVisible(true); 


function hideBusinessProcessFlow()
{
    Xrm.Page.ui.process.setVisible(false);
}

function showBusinessProcessFlow()
{
    Xrm.Page.ui.process.setVisible(true);
}

function showHideBusinessProcessFlow()
{
    if (Xrm.Page.getAttribute("new_showbpf").getValue() == true)
    {
        showBusinessProcessFlow();
    }
    else
    {
        hideBusinessProcessFlow();
    }
}

Good source here:
https://www.powerobjects.com/blog/2014/12/11/setting-visibility-of-a-business-process-flow-with-javascript-dynamics-crm-2015/

Hope it helps!
Thank you and God Bless You!