cancel
Showing results for 
Search instead for 
Did you mean: 

Workaround Flow and Canvas App restrictions by using CDS

Background

 

In this article, you will learn the details of how I've managed to work around some of the current restrictions that don't allow some integrations of Power Automate flows in a Power Apps canvas app. NB: this article was due to be posted in the Power Apps blog, but the site is currently being reviewed so, in order to reduce delays, it's being posted here in the related Power Automate blog.

 

I've recently added a Solution package in the Power Apps Gallery for a sample License Plate Reader.

 

Since the Power Automate flow uses AI Builder's text recognition Predict action, it requires to be in a solution (since it's part of the CDS - Current environment connector). From that point on, the Canvas app that I use to capture the image to be analyzed cannot run that flow, because it's a known limitation that Canvas app triggered flows are not available in solutions.

 

That is why I've used a CDS entity and related trigger as a workaround to process the image via a flow and then display the result back in the app.

 

Get the know-how by reading on!

 

Resources

YouTube: overview of the solution 

GitHub: solution package to install the app and required resources in your environment.

Blog post: the story behind the app and overall solution.

 

The Recipe

At this point, I'll presume you have read the blog post that explains the app and flow. The focus in this current post is about the integration between the two and it is possible to have an app post an item to CDS then wait for a flow to process it.

 

The steps are as follow:

  1. Create a CDS entity that will store the new request (in this case, with an image to process), with the following fields in my sample app:
    • Name: where the extracted text is to be posted
    • [optional] Image to process: a file or image datatype where the image to process is posted. Yes, the new datatype! 😀
    • Processed by flow: a two option (boolean) field that is set to true once the flow has done its processing so the app can be aware the process has ended2019-12-13_12-35-32.png
  2. Create a Power Automate flow that will process the image (in the sample app via AI Builder's text recognition) and update back the entity's record with a "processed" status, the key steps are:
    • Trigger on CDS - Current environment (When a record is created, updated or deleted)2019-12-18_13-34-14.png
    • [optional] Action on CDS - Current environment (Get file or image content), to retrieve the image to process2019-12-18_13-33-59.png
    • [any other process that is specific to your flow] in my sample app, this is where I call the text recognition prebuilt model from AI Builder and then extract the most predominant text portion
    • Update the record that triggered this flow instance to confirm the flow has processed it2019-12-18_14-05-43.png
  3. Create a Power Apps canvas app that creates the record (in this case, after selecting a new image) and then start a timer to periodically refresh its data source and identify when the record has been processed by the flow to surface the updated information to the end-user
    • Create a connection to the CDS entity the flow is triggered on2019-12-18_14-11-13.png
    • Using a SubmitForm(formname) or a Patch() statement, insert a new row in the entity2019-12-18_14-12-05.png
    • Start a refresh process / loop as follow:
      • Insert a Timer Control in the app2019-12-18_14-14-04.png
      • Use a variable to start the timer2019-12-18_14-14-40.png
      • Use a variable to set if the timer is to be repeated or not2019-12-18_14-15-00.png
      • Set a duration for the timer that is applicable to your scenario2019-12-18_14-15-27.png
      • When the timer ends (OnTimerEnd event), Refresh() the datasource and then validate if the "Processed" field has been updated for that newly created row. Based on the result, update the repeat variable2019-12-18_14-15-56.png
      • Display the new data2019-12-18_14-16-46.png

Voilà!

This is just another example that even in a low code platform we can work around some of the current limitations and still be able to use the power of the AI Builder capabilities that are only available in Power Automate within a Power Apps canvas app.

 

Some of you may wonder why in the current scenario, it's not using the new Text Recognizer component that has been released in preview just prior to the holidays. The use of a Power Automate flow still makes sense because the only data currently provided by the control is the recognized text but no information about the size of the text and thus determine if it's the License Plate number.

 

Don't hesitate to download the solution from the gallery, edit the app or flow, adapt it, comment below, etc..

 

Learn and explore

 
The Power Platform really allows business users to resolve business issues quickly while ensuring organizations that the safeguards can be put in place to protect their data and reputation. Make sure to learn and explore the capabilities first in a development/community environment. I hope this article has been useful for you, don't hesitate to share and comment back.
 

About me

 

I'm Éric Sauvé, aka ZePowerDiver, solution architect and team lead at XRM Vision. Recognized as MCT and Business App MVP. I'm a community leader for TDGi's global hackathons in Canada. Power Platform enthusiast, delivering App in a Day sessions, leading local community events such as Montreal Power Platform Happy Hour, actively participating in Montreal Business Application User Group and speaking in Power Platform and Dynamics CE related conferences.
 

You can reach me on:

 

 

Keep on Diving!

 

Meet Our Blog Authors
  • Experienced Consultant with a demonstrated history of working in the information technology and services industry. Skilled in Office 365, Azure, SharePoint Online, PowerShell, Nintex, K2, SharePoint Designer workflow automation, PowerApps, Microsoft Flow, PowerShell, Active Directory, Operating Systems, Networking, and JavaScript. Strong consulting professional with a Bachelor of Engineering (B.E.) focused in Information Technology from Mumbai University.
  • Encodian Owner / Founder - Ex Microsoft Consulting Services - Architect / Developer - 20 years in SharePoint - PowerPlatform Fan
  • Cambridge UK Power Platform User Group Leader, Technical evangelist and speaker. Always says yes to coffee! #LetsGetCoffee
  • Passionate #Programmer #SharePoint #SPFx #Office365 #MSFlow | C-sharpCorner MVP | SharePoint StackOverflow, Github, PnP contributor
  • I am building business processes and applications that are easy for users' to stick to, so they can follow and understand them. In overall I transform processes to be more reliable and effortless. I am a proud co-organizer of SharePoint Saturday Warsaw and active community member, blogger and international speaker.