PCF Button Control triggering Flow (alternative)

There’s a lot of examples out there of PCF Button Controls using JScript to trigger a Power Automate Flow. This is nothing new. But most of them reference a Flow created using a HTTP trigger. The purpose of the HTTP trigger is primarily for starting a flow from an application that’s NOT a Power Platform app. While it works, it’s not necessarily the best approach. You have to secure that end point, and you should monitor that Flow for suspicious activity.

The approach I want to propose keeps it all within the context of the application.

The approach is as follows:

  • You can create a simple hidden choice field, defaulted to false/no.
  • Your PCF Control can switch the choice to true/yes, then trigger a form save.
  • Your Flow trigger looks at this hidden field, and on the condition of value being true/yes, executes the Flow.
  • You then set the choice field back to false/no with a business rule.

Now everything happens within the application.

Your control code could look something like the section below:

var _btnName = this._choiceFieldName;

Xrm.Page.getAttribute(_btnName).setValue(true);

Xrm.Page.data.save();

Enjoy!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

A WordPress.com Website.

Up ↑

%d bloggers like this: