Hi,
I'm currently trying to force the business process to move to the next stage if the user saves. This works when the record already exists aka updating the form, but I cant seem to get it to work when the record is new aka creating a record.
I'm currently trying to save the record first, then wait for the success callback then I will use the openEntityForm(). But it doesn't seem to work.
Any Ideas?
function moveNextStage()
{
var activeProcess = Xrm.Page.data.process.getActiveProcess();
if (activeProcess != null)
{
var process = Xrm.Page.data.process.getActiveProcess().getName();
if (process == "Case - Sales Process")
{
var stage = Xrm.Page.data.process.getActiveStage().getName();
if (stage == "Activity")
{
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());
}
});
}
}
}
}
*This post is locked for comments
I have the same question (0)