Calling Microsoft Flow in Canvas application.

 Hello Guys,

In our previous blog we have seen how to make attachment control visible in canvas application. Today we will see how to make a call of MS Flow in canvas application also how to upload files using MS Flow in SharePoint site.



Do follow us to know more about Dynamics and Power Platform. Also if you like our blog then please comment and share this blog with your friends.

We will be working with the same example which we have used in our previous blog. As you can see in below image we have already added an attachment control to the screen and changed the back color of the screen.



Now we will be adding one button on the screen. On click of the button we will be uploading files which are available in attachment control.



Now we will declare two variables which are used for set Entity name and Record GUID of the entity. Select the screen and select its On Visible event and write below formula. Here for demonstration purpose we are using contact entity and have created one contact record named "Ravishchandra Gupta". So will use GUID of this record as hard coded. In our upcoming blogs we will see how to pass this two values dynamically.



Now we will be writing formula for retrieving attachment and will store it in one variable. Select the button and select it's On Select event and write below formula. 



So now we have attachment, attachment name, entity name and record id. Now we will create one MS Flow which will upload this attachment to the SharePoint site. 

Navigate to https://us.flow.microsoft.com and select your environment. Click on create and select instant flow. Configure it as below.




Add a new step. Search initialize variable. Configure it as below.




Now click on value text box in the Entity Name step and click on "Ask in Power Apps" in Dynamic Content.




Now add a new step and initialize two more variables as shown below.




Now add a new step and search switch and configure it as below.




Add a new step in case block of contact and search list records and configure it as below.




Add a new step below the previous step and search create file and configure it as below.




concat('/contact/',first(outputs('List_Document_Locations')?['body/value'])?['relativeurl'])

Now add a new step below the switch case and search Respond to power apps and configure it as below.




So our flow is ready now. Now we will call this flow from our canvas application. Go back to the canvas application and click on Action in the menu select Power Automate. Add flow which you just created.

Now select the button and replace the On Select formula as shown below.




So our flow is ready. Now we will run it.






Hope it helps...




Comments

Post a Comment

Popular posts from this blog

Read Only Sub Grid & Editable Sub grid in Dynamics 365

Using Pipelines in Power platform for deploying solutions to environments.

Understanding Sales Process in D365.