Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

addOnStageChange() called twice

Posted on by 5

Hello,

I am writing javascript to call function on change of Business Process Flow. So in order to achieve above i have registered addOnStageChange() event as shown below:

//Function to call on-load
onLoad(executionContext: any, lockOrderFlagName: string, myAbilityFlagName: string, configRecordName: string) {

          let functionName: string = "onLoad";
          let formContext: any = null;
          try {

                  //Form Context
                  formContext = executionContext.getFormContext();

                 //Add Stage Change event
                formContext.data.process.addOnStageChange(() => objSalesOrder.onStageChange(executionContext, lockOrderFlagName, myAbilityFlagName, configRecordName));


              }
            catch (ex) {
               objSalesOrder.throwError(functionName, ex);
             }
}

Issue:

Every time change the BPF Stage the above handler i.e. objSalesOrder.onStageChange is executed twice.

Any help will be appreciated!

Thanks!

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: addOnStageChange() called twice

    Hi,

    So has this problem been solved?

    If this helped you, I'd appreciate it if you'd mark this as a Verified Answer, which may in turn help others as well.

    Best Regards,

    Frank Gong

  • Tekka Profile Picture
    Tekka 5 on at
    RE: addOnStageChange() called twice

    Hi @Frank

    it only happens when I newly create the record and move the bpf stage.

    After refreshing the form it is working as expected.

    Thanks for your response!

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: addOnStageChange() called twice

    Hi,

    Have you checked whether you have other triggers on it, you can refer to the following post:

    Dynamics crm Workflow executed twice on change Stage BPF - Microsoft Dynamics CRM Forum Community Forum

    If this helped you, I'd appreciate it if you'd mark this as a Verified Answer, which may in turn help others as well.

    Best Regards,

    Frank Gong

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

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans