How to Trigger Power Automate Flow from Power Apps Portals

This blog article will be discussing how you can trigger power automate flow from the power apps portal without navigating entity forms in the portal. As we you may know, that creating and updating data from an entity or web form can trigger flows because now portals can now be provisioned on the Common Data Service Database. Today, I will show you how to update CDS data by triggering power automate flow from a portal web page without submitting or navigating away from the page. 

I have created an editable grid on the power apps portal web page where users can update CDS data. They don’t need to open a web or entity form for each record to update them one by one. I took a simple example here. I created a table (Entity) named CLASS in CDS and add a few columns to it. 

computer science

The first step is to retrieve the class records into the power apps portal web page where portal users can update it. Keeping it simple, we will be updating class descriptions in series from a portal web page without needing to submit a form. It is simple but hopefully will help in understanding the process.  

I used Liquid FetchXML tags to retrieve records on the portal web page. You can use FetchXML builder to compose these statements.  

FetchXML builder

Editable Grid in Power Apps Portal web page: 

I created a custom web template to retrieve and display class records on the list on a web page. I used the accordion-style to show the records name and hide the description grid on the web page as it could be lengthy. 

Power Apps Portal web page

In this chunk of code, I set the class description value to HTML element textarea to be modified on the portal web page. I set the CDS record ID to textarea tag id, assign each control a unique id, and set the accordion button name to class name. I added a button beside the editable grid, which will pass the GUID of record to the JavaScript function.  

The result looks like the below image on the portal web page.   

portal web page

Create Automated Cloud Flow: 

The next step is to pass user edits to update the record in Common Data Service. So, we will use Power Automate Flow to update the corresponding record in CDS. We can call FLOW from the power app portal by using the HTTP Request trigger. 

Automated Cloud Flow

This HTTP request accepts data in a JSON string. So, we will pass the JSON string to configure it. We can define our sample JSON string in the custom web template.  

I added a JavaScript function “updateRecord” to the custom web template, which will trigger when portal users click on the update button as we have set GUID of record to textarea tag id and passed it to JS function. We will use this GUID in our sample JSON as defined below. 

HTTP request

This sample string will produce an actual JSON string. You can use this sample JSON string into the HTTP request body and click the “Generate from Sample” button to get the actual JSON string.   

JSON string.

When you click the Done button, it will produce a JSON schema for you. Our next step is to update the CDS record by using data collected from the HTTP request trigger. You can use Common Data Service (CDS) current Update connector to update class record in CDS. 

Common Data Service (CDS)

We can get “course Id” and “course description” from the HTTP request trigger and set it to update connector to update class data in CDS.  

course description

When you save the flow, it will generate an HTTP POST URL that can be used in the JS function to trigger the flow when an update occurs to record on the portal page. 

HTTP POST URL

You can test the power automate flow by using POSTMAN to ensure that the JSON will update CDS records.  

Our last step is to add HTTP POST URL to JavaScript function defined in web template to trigger FLOW when the portal user clicks the update button on the web page. 

POSTMAN

You can navigate to a portal page where a list of records is displayed and update the class description grid of any record to test the function. 

Conclusion 

This blog covers how the power automate flow can be used in the power apps portal. You can trigger flows to perform tasks beyond creating and updating the data. Power automate flows can be used to trigger a classic workflow in the power apps portal. You can create a custom web template or use existing templates to code JS function with liquid.  If you have any questions, please reach out to us via the contact us page!

   

Leave a Reply

Your email address will not be published. Required fields are marked *