Thursday 14 June 2018

Switch Business Process Flow using JavaScript based on CRM Form’s field value

Dynamics 365: switching UI business process flows

Description:
In this example we explain that how to switch business process in Dynamic CRM using JavaScript. Or change the business process flow using JavaScript in Dynamic CRM.or JavaScript code to change or switch business process in Dynamic CRM.

Here we demonstrate that how to switch Business Process Flow using JavaScript based on Dynamic CRM form’s field value. We have requirement to switch the business process on Case Origin like if Case Origin Equal Website then set Business Process like Website to Case, if Case Origin Equal Email the set Business Process like Email to Case.

So below is the JavaScript code that demonstrate that how to change or switch Business Process in Dynamic CRM.
Function:

function ChangeBusinessProcess() {
            // If not new Case form
            if (Xrm.Page.ui.getFormType() != 1) {
                // Read Origin Option text
                var origin = Xrm.Page.data.entity.attributes.get("caseorigincode");

                if (origin && origin.getText()) {
                    var caseOrigin = origin.getText();

                    // Get Business process flow id
                    var processFlow1Id = "6CD44946-0DC5-47E3-9B62-6D7309254710";
                    var processFlow2Id = "0B3A94CD-CD43-4F49-A9A3-93C4AC684CFA";

                    // Get Current Active Process Id
                    var activeProcess = Xrm.Page.data.process.getActiveProcess();
                    var currProcessId = activeProcess.getId();

                    if (caseOrigin.toLowerCase() == "website") {
                        // Change the process only if current Active Process not the Target one
                        if (currProcessId.toLowerCase() != processFlow1Id.toLowerCase()) {
                            // Switch to the "Website to Case"
                            Xrm.Page.data.process.setActiveProcess(processFlow1Id, myCallBack);
                        }
                    } else if (caseOrigin.toLowerCase() == "email") {
                        // Change the process only if current Active Process not the Target one
                        if (currProcessId.toLowerCase() != processFlow2Id.toLowerCase()) {
                            // Switch to the "Email to Case"
                            Xrm.Page.data.process.setActiveProcess(processFlow2Id, myCallBack);
                        }
                    }
                }
            }
        }

        // Call back function post Process flow switch
        function myCallBack(response) {
            if (response == "success") {
                alert("BPF changed !!!");
                // Save the form
                Xrm.Page.data.entity.save();
            }
            else {
                alert("Error changing BPF!!!");
            }
        }



25 comments:

  1. ●Exising without the answers to the difficulties you’ve sorted out through this guide is a critical case, as well as the kind which could have badly affected my entire career if I had not discovered your website.
    Digital Marketing Training in Chennai

    Digital Marketing Training in Bangalore
    Digital Marketing Training in Pune

    ReplyDelete
  2. This is a nice post in an interesting line of content.Thanks for sharing this article, great way of bring this topic to discussion.
    Click here:
    python training in velachery
    Click here:
    python training in OMR

    ReplyDelete
  3. Its really an Excellent post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog. Thanks for sharing....
    python training institute in marathahalli | python training institute in btm

    ReplyDelete

  4. When I initially commented, I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get several emails with the same comment. Is there any way you can remove people from that service? Thanks.

    Amazon Web Services Training in Pune | Best AWS Training in Pune


    AWS Training in Pune | Best Amazon Web Services Training in Pune

    ReplyDelete
  5. Good Post, I am a big believer in posting comments on sites to let the blog writers know that they ve added something advantageous to the wordevops online training

    aws online training

    data science with python online training

    data science online training

    rpa online training ld wide web.

    ReplyDelete
  6. Great info! I recently came across your blog and have been reading along. I thought I would leave my first comment. I don’t know what to say except that I have.

    digital marketing course in chennai
    digital marketing training in chennai

    ReplyDelete
  7. I must thank you for the efforts you have put in penning this site. I am hoping to see the same high-grade content from you later on as well. In fact, your creative writing abilities has motivated me to get my very get own website now ;)

    ReplyDelete

  8. Thanks for sharing such a wonderful blog with us. It makes the business develop more and more.
    DevOps Training In Hyderabad

    ReplyDelete
  9. I really happy found this website eventually. Really informative and inoperative! Thanks for the post and effort! Please keep sharing more such article.

    DevOps Training in Hyderabad

    ReplyDelete
  10. Nice article and thanks for sharing with us. Its very informative


    Plots in CHITUKULA

    ReplyDelete
  11. Infycle Technologies offers the best Data Science Certification in Chennai and is widely known fots excellence in giving the best Data Science training in Chennai. Providing quality software programming training with 100% placement & to build a solid career for every young professional in the software industry is the ultimate aim of Infycle Technologies. Apart from all, the students love the 100% practical training, which is the specialty of Infycle Technologies. To proceed with your career with a solid base, reach Infycle Technologies through 7502633633r i.Grab Data Science Course in Chennai | Infycle Technologies

    ReplyDelete
  12. Is this blog important for business? That's a questionBuy yahoo accounts that I get asked quite frequently and the answer is a resounding yes! This blog has been one of the most powerful tools to increase my online sales dramatically. It's not a blog where I post sad stories or thoughts about my last vacation or what I ate for dinner the night before. Rather, it's a place where I post up relevant articles related to my business that are regularly monitored and updated so that my visitors always stay well informed and up to date on what I'm doing and why.Buy tinder accounts

    ReplyDelete
  13. This article is a guest post on the significance of this post and how important it is for business
    Buy facebook accounts to post it on their websites. In this post we are going to discuss why it is important for businesses to post a sign up sheet and other important things that one should consider when making this big investment. When making a big investment such as this one is very important to consider all aspects and that is why it is important for business to make sure that they post this on their websites. For those who are not able to make this post or understand its importance you can always check this out at my blog for more information.
    Buy snapchat account

    ReplyDelete
  14. This is an informative blog. If you are looking for an online store for appliances. Feel free to visit Brands Direct Online to know more about our products

    ReplyDelete
  15. Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!
    Buy Gmail Accounts
    Buy Gmail Accounts

    ReplyDelete
  16. Really an awesome blog and useful content. Keep updating more blogs again soon. Thank you.
    Best Data Science Training in Hyderabad

    ReplyDelete
  17. Гадание козерог - это верный метод узнать судьбу с применением каких-либо объектов и средств. Потусторонние силы и всевозможные способы ворожения научно не доказаны, но все же различные люди в них верят. Номенклатура деяний, сориентированных на предвидение будущего, отмечают как хиромантия.

    ReplyDelete