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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Advance BPF stage from...
Power Apps
Unanswered

Advance BPF stage from the view with JS

(0) ShareShare
ReportReport
Posted on by 35

Hello there!

 

I'm currently developing a Model Driven Apps with a Business Process Flow. Now I got the requirement of advance the BPF to the next stage from the main view of the entity. I created a custom button in the command bar in order to achieve that.

AntonioMF_0-1677223329569.png

AntonioMF_1-1677223329653.png


The goal for this button is to select multiple records and advance their stage. Notice that I pass "PrimaryControl" parameter to get the executionContext of the selected records.

I post my JS code:

 

function BPFMoveNextStageSelected(executionContext) {
 //Initiated Form Context
	debugger;
 var formContext = executionContext;
	//Moving BPF to the next stage
	formContext.data.process.moveNext(function callBack(result) {
		if (result == "stageGate") {
			alert("Debe completar los campos obligatorios antes de avanzar de estado");
		}
		else if (result == "end") {
			formContext.data.process.setStatus("finished", function callBackResult(stringRes) {
				if (stringRes == "invalid")
					alert("Debe completar los campos obligatorios antes de avanzar de estado");
			});
		}
		else if (result == "dirtyForm") {
			alert("Debe guardar el formulario para poder avanzar de estado");
		}
		console.log(result);
	});	
}

 
In this code when I access to some attribute inside fromContext variable I get this error in Chrome developer tools:

AntonioMF_2-1677223329899.png


Any help is appreciated 🙂

I have the same question (0)
  • Verified answer
    a33ik Profile Picture
    3,306 Most Valuable Professional on at

    formContext.data.process names are only available on the form of the record only. You will have to work with it using it as a data - https://learn.microsoft.com/en-us/power-automate/developer/business-process-flows-code

  • AntonioMF Profile Picture
    35 on at

    Hi @aa33 thanks for answering!

    I check the link above and I saw that I will have to hardcode stages GUID right?
    I was trying to use moveNext JS method in order to follow automatically the BPF and check all the conditions to go through one branch or another. Is this possible to do with the solution you mentioned?

    Regards.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard