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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 530

#2
WarrenBelz Profile Picture

WarrenBelz 459 Most Valuable Professional

#3
Haque Profile Picture

Haque 314

Last 30 days Overall leaderboard