Passing objects to Power Automate from Canvas App

In this article, we will see how objects/variables can be passed from a canvass App to a Power Automate. The pre-requisite needed to be able to follow in this post are:

  • Access to Canvas App
  • Access to Power Automate
  • Lastly, a dynamics 365 instance

Here, I have created a canvas with two button – Call PowerAtomate and Create Collection

In the OnSelect of the Create Collection buttion, put the below formular:

ClearCollect(object1,{Name: "Victor", LastName:"Onyebuchi", Number: "405" })

The above method will create a list with one record containing Name, LastName, Number properties. Read more on how to use clearcollect method here.

Let’s leave the Canvas app, go create a power automate flow.

In the above image, I have created a power automate with the trigger being power App, next in the flow I have added the initialise variable. Here the object would be received from the trigger;

Next, the returned objects needs to be parsed using Parse Json action:

In the content, pass your initialise variable value and in the schema, click on the generate from sample button and paste this – {Name: “Victor”, LastName: “Onyebuchi”, Number: “405” }. The next action is creating a record in dynamics using the variables from the parsed JSON object. Save your power automate with a name of your choice.

Let’s go back to the canvas up earlier created, in the onSelect event handler of the “Call Powerautomate” button “, click the Action button that can be found in the ribbon of the canvas app, and then power automate. The power automate earlier created will appear, click on it to add it on the OnSelect event handler of the call power automate button:

In the Onselect method, edit the method to the follow, using the name of the power automate created earlier;

PassJsonFromCanVasApp.Run(JSON(object1))

The collect object1 created by clicking the “create collection” buttion is passed in, converted to a JSON object.

Run your canvas app, it should trigger your power automate, and perform the actions in the flow of the power automate.