Hello everybody!
I don't want make this script too long, so I copy here only the "fail section"
Explanation:
There is a Brach-Stage (The second) for Stage1 [Stage1 can move to StageA or StageB ...it's a example]).... I've use this scrip with StageA (Obviosly with his var) and it work fine.
Work Fine => It move to previous stage (Active), delete somes fields in both Stages (In Stage1 it delete the "Set In" branch Stage [Move_StageA] and in StageA it delete all values). Also it re-load the form, so the User have his screen in the Actual ActiveStage.
My Problem:
If I use this script like it's that copy here, the form move to previous stage and re-load, but like you can see... the var in the success moment don't delete (it's because I've the //). But If I delete this // ... that happened:
-The form don't re-load (the active-stage is Stage1, but the view-stage is StageB).
-The fields don't clean (the only field that set a null value is "Desca1").
The Script:
if ( Desca1 == true){Xrm.Page.data.process.moveNext(function (status){ console.log(status); console.log(Xrm.Page.ui.getFormType()); if (Xrm.Page.ui.getFormType() == 1 && status == "invalid") { Xrm.Page.data.entity.save().then(successCallback, errorCallback); function successCallback() { Xrm.Utility.openEntityForm(Xrm.Page.data.entity.getEntityName(), Xrm.Page.data.entity.getId()); } function errorCallback() { console.log("error"); } } else if (status == "success") { Xrm.Utility.openEntityForm(Xrm.Page.data.entity.getEntityName(), Xrm.Page.data.entity.getId()); } }); } // Indicar que si Retomar_descalificado_# es Renudar > SetR# son Falsos if ( RetDes1 == true){ var SetR1 = Xrm.Page.getAttribute("mk_activar_requerido_1").setValue(false); } // Estado1 = Renudar Proceso --> Volver a Etapa 1, el cual es el primero por lógica en ser activo. if ( RetDes1 == true){Xrm.Page.data.process.movePrevious(function (status){ console.log(status); console.log(Xrm.Page.ui.getFormType()); if (Xrm.Page.ui.getFormType() == 1 && status == "invalid") { Xrm.Page.data.entity.save().then(successCallback, errorCallback); function successCallback() { Xrm.Utility.openEntityForm(Xrm.Page.data.entity.getEntityName(), Xrm.Page.data.entity.getId()); } function errorCallback() { console.log("error"); } } else if (status == "success") { //var RetDes1 = Xrm.Page.getAttribute("mk_retomar_descalificado_1").setValue(null); //var Desca1 = Xrm.Page.getAttribute("mk_descalificado_1").setValue(null); //var MotDes1 = Xrm.Page.getAttribute("mk_motivo_descalifica_1").setValue(null); //var manic = Xrm.Page.getAttribute("mk_manact_inicial").setValue(null); //var reuini = Xrm.Page.getAttribute("mk_reunion_inicial").setValue(null); Xrm.Utility.openEntityForm(Xrm.Page.data.entity.getEntityName(), Xrm.Page.data.entity.getId()); } }); } }
So... Any Know Why I'm getting trouble with this part?
Edit Post: To Help with "undestand" it, my problem is that in this Stage (I don't know why) the Script only ejecute one of the
scripts in RED, so if I "//" the others I can "set" with script will work, but the idea is that ALL work, like to StageA