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!

26 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This method will not work on CRM for Tablets

    ReplyDelete
    Replies
    1. Yes, because it is unsupported way through DOM access. Btw if you are using CRM 2015, can try supported way using:

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

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

      Delete
  3. How to you find out the name of the business flow?
    In your example it is 'header_process_d'

    ReplyDelete
  4. Hi Aileen,

    I have experienced your post and your proposed solution function perfectly at on load, but after create the register, the business process flow is showed again. I put an alert in the "on save" call and the function is called 2 times, but, afterall, the business process flow is showed again.

    Has any sugestion about this?

    Thank´s in advance.

    Marcelo Rigoni

    ReplyDelete
    Replies
    1. Marcelo,

      For CRM 2015, please use supported way:
      Xrm.Page.ui.process.setVisible(false);

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

      I think you have read that article? Btw, what do you mean register? create record?

      Delete
    2. Hi Aileen,

      Excuse my english ;).


      Yes, what I want to mean was create a record (an opportunity). I used the sample proposed by Joe in PowerObjects but the result was the same: after to save the opportunity by the first time, the BPF is showed again.

      Thank you again.

      Marcelo

      Delete
  5. SO .. I have this issue with Business Process Flows:

    I have an entity called LOCATION, with multiple forms, named as follows:
    "CSR Location"
    "Form X" <-- (represents all other forms)

    I have this code in the onLoad Event of all forms:

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

    function HideBusinessProcessFlow() {
    var formLabel = Xrm.Page.ui.formSelector.getCurrentItem().getLabel();
    if (formLabel != 'CSR Location') {
    hideBusinessProcessFlow();
    }
    }

    The issue is that it works....mostly. If I am on any 'Form X' and save a NEW form, when the page re-loads the BPF displays. If I then reload the page again, the BPF is hidden.



    ReplyDelete

  6. شركة كشف تسربات المياه بالاحساء

    الموقع الرائد فى عالم الخدمات المنزليه والاول بالمملكه العربيه السعوديه لما يتمتع به من خدمات مميزه ، فالبرغم من اننا مؤسسه ربحيه الا ان مزاولة نشاطتنا كلها مرتبط على نحو وثيق بتلبية طلبات وحاجات عملائنا ولتحقيق ذلك الهدف نقدم لك كافة الخدمات الشامله بالالتزام الصارم وبأرقى المعايير المهنيه المتطوره
    فلدينا خبره طويله فى مجال التنظيف ومكافحة الحشرات والكشف عن التسربات وتسليك المجارى وعزل الاسطح ونقل الاثاث وتخزينه بكفاءة منقطعة النظير ، لا تتردد واتصل بموقع مؤسسة الحرمــين فخدماتنا ليس لها بديل واسعارنا ليس لها مثيل ،ولدينا فريق عمل يتصل مع العملاء على جسور الثقه والصدق والامانه فى العمل ، وهدفنا هو ارضاؤك وراحتك ، لا تقلق ونحن معك .. لا تجهد نفسك ونحن تحت امرك ورهن اشارتك .
    أبرز خدمات مؤسسة الحرمــين
    شركة كشف تسربات المياه بالجبيل

    كشف تسربات المياه بالجبيل


    شركة عزل اسطح بالاحساء

    ReplyDelete
  7. شركة مكافحة بق الفراش بجدة واحدة من أفضل شركات المملكة فى مكافحة الحشرات رش بق الفراش بجدة فنحن نعطيك نتائج ممتازة خلال فترة زمنية قصيرة جداً شركات رش البق بجدة فقط إتصل بنا وسيصلك مندوبي الشركة رش بق الفراش بجده ولأننا متميزون أصبحة الشركة الاولى فى مكافحة الحشرات الضارة و مكافحة بق الفراش بجده

    ReplyDelete

My Name is..