Thursday 11 June 2020

Create Record in Dynamics 365 CE Using Power Apps and Power Automate (Flow)


Hi Everyone,

This is my first post on Power Apps (Canvas App) and could be very basic to most of the people but it would helpful for the beginners like me.

  • Login to Make.PowerApps.Com
  • We can directly create an App and Flows from the navigation as below but I would recommend to create a Solution first and then create App and Flow in that.
  • Create a solution with the name as you wish and select the right publisher.
  • Open the solution and click on New from Top Navigation  --> App  --> Canvas App  --> Phone form factor(I have selected for it Phone UI for this post, you can select as per your requirement)
  • Save the App first with desired name. You can use Ctrl+S as a shortcut.
  • You will get the new tab in the browser as below.
  • From Insert Menu add required text boxes, labels and a button on the Screen. Make sure you use good naming convention as a best practice.
  • Go back to the solution again and create a flow as below.
  • Take trigger as PowerApps.
  • Declare two variables and set them to get the value from Power App. We have "Ask In Power Apps" in the value for getting the parameters.
  • Add a step to create a contact in Dynamics 365 CE using Common Data Service Connector and set the values. We cannot use Common Data Service Current Environment Connector as there is an OOB issue with that. Check this for more information on that.
  • Add "Respond to PowerApp or flow" and select response which you would like to send. Here I have selected Text and gave the response as below.
  • Let's go back to our canvas app and click on Action on top  --> Power Automate.
  • It will show the Flows that you have in the Organization and select the flow the one which you have created.
  • Call below OnSelect of the Create Contact button.

Set(flowResponse, NewContactCreatingFromFlow.Run(TextFirstname.Text, TextLastname.Text)); Notify(flowResponse.message,NotificationType.Success, 3000);

The code is simple, we are calling the flow with the parameters and storing the response in a variable called flowResponse. After the execution of flow is completed, we are notifying the user with the response that we got from Flow and for this we are using Notify command.

And Let's run it..


Hope this helps.

--
Happy 365'ing
Gopinath

No comments:

Post a Comment