Microsoft replied to my ticket to say the setActiveProcess can not be used in the new UI and referred me to this article: docs.microsoft.com/.../model-business-process-flows
I am confused at this response because it does seem to work for saved case records. So I assume then that the issue is how the form and components are loaded now in the new UI. They have given me some sample code to try. I will need to change for the case entity:
function doSomething(executionContext) {
var formContext = executionContext.getFormContext(); // get the form Context
var recid = formContext.data.entity.getId();
recid = recid.replace("{", "").replace("}", "");
var entityFormOptions = {};
entityFormOptions["entityName"] = "opportunity";
entityFormOptions["entityId"] = recid;
entityFormOptions["useQuickCreateForm"] = false;
// Set default values for the Contact form
var formParameters = {};
// Open the form.
Xrm.Navigation.openForm(entityFormOptions, formParameters).then( function (success)
{ console.log(success); }, function (error) { console.log(error); });
var req = new XMLHttpRequest();
req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v9.0/SetProcess", true);
req.setRequestHeader("OData-MaxVersion", "4.0");
req.setRequestHeader("OData-Version", "4.0");
req.setRequestHeader("Accept", "application/json");
req.setRequestHeader("Content-Type", "application/json; charset=utf-8");
//req.setRequestHeader("Prefer", "odata.include-annotations=\"*\"");
req.onreadystatechange = function ()
{
if (this.readyState === 4) {
req.onreadystatechange = null;
if (this.status === 204) {
//result = JSON.parse(this.response);
//callback(result);
Xrm.Navigation.openForm(Xrm.Page.data.entity.getEntityName(), Xrm.Page.data.entity.getId());
//formContext.data.refresh(true);
} else {
Xrm.Navigation.openAlertDialog(this.statusText);
}
}
};
req.send(JSON.stringify(
{
"Target": {"@odata.type": "Microsoft.Dynamics.CRM.opportunity", "opportunityid": recid},
"NewProcess":{"@odata.type": "Microsoft.Dynamics.CRM.workflow", "workflowid": "e95233b8-42b4-4432-a941-ed387a4206c2"} // Desiered BPF to change to
}
));
}
Not sure this is going to do what I want. I might just hide the BPF and switch onLoad of the record after the first save.