web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Unable to change the active stage field on the form when changing the process

(0) ShareShare
ReportReport
Posted on by 187

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 

6201.2019_2D00_02_2D00_06_5F00_10h20_5F00_09.png

 

after changing the process, the field still have the same value :/ and it changes only if we move the process to another stage

 7367.2019_2D00_02_2D00_06_5F00_10h23_5F00_30.png

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)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans