web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Service | Customer Service, Contact Center, Fie...
Suggested Answer

Is it possible to open a new record and be in the 2nd stage of Business Process Flow via JS?

(0) ShareShare
ReportReport
Posted on by 15

Hello Community,

I am using Dynamics 365(Version 8.2.8.15 On-Premises). I have a business process flow in quote entity with 3 stages. On second stage, there is a date field.On change of that field, I am opening a cloned copy of an existing record. Clone is working for me but my problem arises when new cloned record is opened, it opens on the 1st stage of BPF. Since I was already on the second stage of BPF while opening a cloned record, I need a new cloned record opening on the 2nd stage of the BPF.  

I did try using setActiveStage,moveNext based on the articles but because of my limited JS knowledge , i am not able to achieve what I need.

Could someone tell me if it is possible to load a new record and  be in the 2nd stage of a BPF? Or, Onload of a record does BPF always opens on a first stage? If its possible , could you guide me on how to achieve it?

This is the code I am using to open a new cloned record. While this record opens, I want the BPF in the second stage.

pastedimage1586095039775v1.png

Any help would be greatly appreciated! 

Thankyou.

I have the same question (0)
  • Suggested answer
    Ankit Sabharwal Profile Picture
    on at

    Hello Partner,

    Hope this post finds you well. Please debug your code, as up to my knowledge openEntityForm() method opens the record from the database and it fetches the record from database. Thus you haven't save the date field when changing it, as your method will trigger as soon as you tab out. 

    This is also the reason that your BPF starts with stage 1 as this information is not yet saved to the database.

    So if you want to clone the record , it needs to be first saved.

    Xrm.Page.data.entity.save()

    This needs to be saved first.

    Thanks,

    Ankit sabharwal

     

    Hope this helps.

    Best regards,

    Ankit

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

  • Dynamics CRM 2020 Profile Picture
    15 on at

    Thankyou for the reply Ankit.

    I did try the following code onload of a page. Since the change of the date field was triggering a clone, date field will always be populated. So I checked if the date exist, if yes, try to set the active stage. It's not working for me. The guid is the second stage guid.

    function onLoadQuote() {

       //check if the date field contains data

       var dateSent = Xrm.Page.getAttribute("po_datessent").getValue();

       if (dateSent != null) {

           var GUID = "a5478548-6e09-40dd-b897-930f58929290";

           Xrm.Page.data.process.setActiveStage(GUID, function (result) {

               if (result == "success") {

                   alert("Success");

               } else {

                   alert("Invalid");

               }

           });

       }

    }

  • Suggested answer
    Ankit Sabharwal Profile Picture
    on at

    Hello Partner,

    You can try to use setActiveStage() method and register it on OnLoad. This method should be fire when you clone the record. For this information to persist, you can have a boolean field, which can be set, when you clone the record.

    If this field is true, then setActiveStage to stage 2 else stage 1 will be your active stte.

    Thanks,

    Hope this helps.

    Best regards,

    Ankit

    Please mark as verified if the answer is helpful. Welcome to join hot discussions in Dynamics 365 Forums.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Service | Customer Service, Contact Center, Field Service, Guides

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 20 Super User 2025 Season 2

#2
TAHER Mehdi Profile Picture

TAHER Mehdi 14

#3
LightningStrikes Profile Picture

LightningStrikes 9

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans