
Hi Community,
this is another episode from my love story with the BPF in Dynamics <3
after setting up a field in the opportunity form to store the active stage, we've encountered a serious problem when we change the BPF to another one
this is an example:
Our first process is applied, and the active stage is populated with the correct value
after changing the process, the field still have the same value :/ and it changes only if we move the process to another stage
Note that the process is changing with a javascript triggered by the field market on the same form
I've tried changing my script as below :
if( (formContext.getControl("market2id").getAttribute().getValue()[0].name).indexOf('ISD') == 0 )
{
//changing the process after checking the value of the specified field
formContext.data.process.setActiveProcess(idProcess_ISD, function (result) {
if (result == "success"){
var opportunityID= formContext.data.entity.getId();
var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>"+
" <entity name='bpf_isd_opportunities'>"+
" <attribute name='businessprocessflowinstanceid' />"+
" <filter type='and'>"+
" <condition attribute='bpf_opportunityid' operator='eq' uitype='opportunity' value='"+opportunityID+"' />"+
" </filter>"+
" </entity>"+
"</fetch>";
// retrieving the process flow instance id of the target process
Xrm.WebApi.retrieveMultipleRecords("bpf_isd_opportunities","fetchXml= " + fetchXml).then(
function success(result) {
console.log(result.entities[0]["businessprocessflowinstanceid"]);
var instanceId = result.entities[0]["businessprocessflowinstanceid"];
// retrieving the active stage from the target process
Xrm.WebApi.retrieveRecord("bpf_isd_opportunitieses", instanceId ).then(
function success(result) {
var activeStageIdDisk = result._activestageid_value;
// Displaying the Value --> OK
console.log(activeStageIdDisk);
// changing the field value --> KO
formContext.getAttribute("activestage").setValue(activeStageIdDisk);
},function (error) {console.log(error);}
);
},
function(error) {
console.log(error.message);
}
);
}
});
}
THANK YOU ALLLL
*This post is locked for comments
I have the same question (0)