Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Microsoft Dataverse
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 🙂

  • AntonioMF Profile Picture
    35 on at
    Re: Advance BPF stage from the view with JS

    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.

  • Verified answer
    a33ik Profile Picture
    3,304 Most Valuable Professional on at
    Re: Advance BPF stage from the view with JS

    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

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

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Leaderboard > Power Apps - Microsoft Dataverse

#1
mmbr1606 Profile Picture

mmbr1606 22 Super User 2025 Season 1

#2
stampcoin Profile Picture

stampcoin 17

#3
ankit_singhal Profile Picture

ankit_singhal 11 Super User 2025 Season 1

Overall leaderboard

Featured topics