Hi all,
I'm noticing an strange behavior when using JS to change the active BPF stage and I would like to know if I'm doing something wrong. Basically, I have a requeriment on which due to the change of a field, if the new value is "Yes", I need to move the BPF Stage to the next one as the current is already completed. Here's the code I'm using for that:
emScripts.OnPIRFEChange = function () { Xrm.Page.data.save().then(function () { var PIRFE = Xrm.Page.getControl("em_PIRFE").getAttribute(); if(PIRFE.getValue()) { Xrm.Page.data.process.moveNext(function (status) { // I'm excecuting the code below within the callback method as it is async. console.log(status); // Here I get Success. var NextStageID = emScripts.GetNextStageID(); // I confirmed that the ID is correct. Xrm.Page.data.process.setActiveStage(NextStageID, function (status) { console.log(status); // Also here I get Success. }); }); } }, null); };
Once the code finishes, I see that the selected and active stage becomes the one I want, however, this only happens for an average of 2 seconds as after that time the Stage is set back to the one I had before(and I can confirm I have no code that does that). So, not sure what I'm doing wrong, I have tried different ways to fix it but none of them worked as if I don't call the methods as described above, I get "Invalid" errors on the console.
Any workarounds? Thanks in advance!
*This post is locked for comments