Customer Engagement & Dynamics CRM Forum

Expand all | Collapse all

Switching BPF with Javascript and workflow

  • 1.  Switching BPF with Javascript and workflow

    TOP CONTRIBUTOR
    Posted Jun 21, 2019 02:14 PM
    Hi all,
    We're on Dynamics 365 Online CE v9x.  We are using Javascript and a workflow to change the Business Process Flow on the Opportunity form based on a custom field (called Opportunity Type).  This works fine on the main Opportunity form but when a user uses the quick create form it by passes the process and creates the opportunity against the default Business Process Flow (we have 3 BPF's in total).

    The Opportunity workflow is real-time and runs when the record is created and when the Opportunity Type field changes.  When the criteria is met, the workflow updates a custom field (called Script Process Name) with the name of the BPF.  The javascript is then triggered which switches the process.

    Let me know if you need any additional information.

    Cheers.

    ------------------------------
    Mark Aston
    Data Analyst
    Ordnance Survey
    Southampton, UK
    ------------------------------


  • 2.  RE: Switching BPF with Javascript and workflow

    TOP CONTRIBUTOR
    Posted Jun 21, 2019 05:06 PM
    Hi Mark,

    I found a thread with similar issue however it is an old one. I am pretty sure if it was a bug it would have been resolved by MS by now.
    https://community.dynamics.com/crm/f/117/t/183045

    Regardless, when you check the process sessions for the workflow, does it show any instance of the workflow if it succeeded or no trace at all? (Provided you are not deleting the successful instances of workflow through the setting)

    ------------------------------
    Sunil Raheja
    Aha Apps
    Glen Allen VA
    ------------------------------



  • 3.  RE: Switching BPF with Javascript and workflow

    SILVER CONTRIBUTOR
    Posted Jun 24, 2019 11:31 AM
    Make sure you add the script to both forms. The same script should work in both ( as long as both forms have all the fields necessary). One thing i do when creating scripts it i make liberal use of console.log. that way when the page is running i can press F12 and see exactly what is running and when and how far it gets.

    ------------------------------
    Nicholas Anderson
    Information Technology
    Wagstaff Inc.
    Spokane WA
    ------------------------------



  • 4.  RE: Switching BPF with Javascript and workflow

    TOP CONTRIBUTOR
    Posted Jun 24, 2019 11:54 AM
    Thanks for your response @Sunil Raheja​.  The workflow logs aren't kept but the workflow is still updating the Script Process Name field for quick create opportunities.

    Thanks @Nicholas Anderson, we realised this morning that the script hadn't been added to the quick create form.  We've added it but it still doesn't work (I added the Script Process Name to the quick create form too as that was missing).  We'll try the F12 developer tools and see where the process is falling over.
    ​​

    ------------------------------
    Mark Aston
    Data Analyst
    Ordnance Survey
    Southampton, UK
    ------------------------------



  • 5.  RE: Switching BPF with Javascript and workflow

    TOP CONTRIBUTOR
    Posted Jul 02, 2019 10:51 PM
    Mark, Usually a quick create form does not have the BPF in place right? The main form does. So in my opinion, the JS would not find the parameters to update it. It would be a good idea to debug the JS while in action.

    ------------------------------
    Sunil Raheja
    Aha Apps
    Glen Allen VA
    https://www.ahaapps.com/microsoft-dynamics-crm/
    ------------------------------



If you've found this thread useful, dive deeper into User Group community content by role