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

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
dkrishna Profile Picture

dkrishna 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans