Search code examples
javascriptdynamics-crmmicrosoft-dynamicsdynamics-365dynamics-crm-365

Dynamics 365 JavaScript - moveNext (business process flow) function on dirty form. How to prevent double saving?


When i use javascript function to move next stage (formContext.data.process.moveNext(callbackFunction))

on a dirty form it requires fist to save the form. So I save the form and call moveNext function.

moveNext function itself causing second saving - so the process is slow

But when i click the button "Move Next" on a dirty form - it saves and move next in one save - so the process is faster

How can I prevent this double saving when moving next on a dirty form with javascript? Can I call the same function that the Button uses?


Solution

  • This seems a bit hacky, but you could try this:

    if (formContext.data.getIsDirty()) {
        formContext.data.process._getProcessManager().moveToNextStage().then(callback);
    } else {
        formContext.data.process.moveNext(callback);
    }