Building Business Scenarios Using Microsoft PowerPlatform (PowerApps + Flow + PowerBi) P2/3

In this post we will see how we can create/ automate business scenarios with the Microsoft PowerPlatform. (Part 2 of 3)

This post is a continuation on our work item for creating a solution on PowerPlatform for Ctrade Inc. Part 2 – Create a Microsoft Flow to automate processes.

Overview of the Microsoft Flow that we are going to create:

  1. The flow is triggered by the press of a button. Upon triggering the flow, an option set to select multiple options appears. The user can choose all the commodities listed here to get the exchange details.
  2. After the options are selected and submitted, two parallel actions are started.
    1. Initialize an array with the selected options-> HTTP Get request to get exchange details. (we use the https://rest.coinapi.io api to get these details). A foreach loop is run to iterate all the values stored in the array. We enable the concurrent run option to get the details of the commodities in parallel. These details are populated into an HTML table.
    2.  Initialize an array to store the employee email id’s -> query the CDS to get these details -> store the details in an array.
  3. The HTML table created in 2.A is then posted into the teams channel. An Outlook email with options is sent to the manager.
  4. Once the manager selects an option in the email, a message with that option is posted on the teams channel. An email is sent to the employees with the manager’s response. The flow is finally terminated with a successful response code.

Part 2: Microsoft Flow to automate getting details of the Crypto Exchange and approvals from the manager:

Step 1:

Logon to the Microsoft Flow portal -> Select My Flows from the left tab -> Click on New -> Select Create from Blank from the drop-down.

Step 2:

In the Triggers search box, type manual and select the Flow Button for Mobile option. Once the button has been selected, in the same tab Select Add Input -> Text. On the Text Input select the Add a multi-select list of options from the drop down. Now we enter the options (commodities) the user can choose. Now select the New Step option below the manual trigger tab. In the actions search box, type Variable and choose Initialize a Variable from the drop-down. Initialize the variable as an array to save the exchange details. Next, we add a parallel branch from the new step below the Manual trigger tab and initialize another array variable to store the employee emails.

Step 3:

Under the Exchange details variable add a new-step and in action search-box, type and select the apply to each option. Now select the input option from add dynamic content tab and add it to apply to each condition input.

Within the loop, add a new step -> type and select the HTTP Request option from the action search-box. In the HTTP request -> select Method as GET -> paste the URI as shown in the picture. Add the API key header in the headers option -> Select none for the Authentication type option. Within the loop, add a new step -> type and select the append to array variable from the action search-box. Choose the crypto details array variable and set the value to Body of the HTTP request from the dynamic inputs tab.

Now come out of the loop, add a new step -> search and select Create a HTML Table from the action search-box. Format the HTML table with the exchange data as shown in the picture. Note: values of the headers come from the expression: @item()?[‘object name from array’].

Step 4:

Under the emails of employees variable, add a new step-> type and select Get Records (CDS) from the action search box. Select the environment that we created the entities and select the Employee Data entity. Add a new step -> type and select the apply to each action from the action search-box. Select the value output of the CDS from the dynamic input tab and map it as input to the loop. Within the loop, add new step -> type and select the append to variable option from the action search-box. Select the Employee Details variable and point the value to Employee Email of CDS from the dynamic data tab.

Step 5:

Now step outside the parallel steps, add a new step -> type and select Post a Message Teams from the action search-box. Select the team -> team channel -> and message: output of the HTML table. Add a step-> type and select Outlook Email with Options from the action search-box. Enter the email address of the manager, subject and modify the user options. In the advanced options-> body, add HTML to modify the table and select use HTML only option at the end.

Step 6:

Add a new step -> type and select apply to each action from the action search-box. Select the Employee List variable and map to the input for the loop. Within the loop, add a new step -> type and select send an outlook email from the action search-box. Add the current item from the dynamic data tab in the to field of the email. Add a subject to the email and format the body of the email message. Lastly, set the HTML option to true in the Outlook email. In a parallel action, add a new step -> type and select Post a Message Teams from the action search-box. Select the team -> team channel -> format the message.

Step 7:

After the parallel thread, add a new step -> type and select terminate from the action search-box. In the terminate action set status to succeeded. After completing these steps, your flow should look like as shown in the picture below.

After a successful run, the flow run looks like as shown in the picture. Clicking on each tab will display the set of inputs and outputs at that particular step/ action.

Outlook email with options to the manager:

Outlook email to the employees after manager decision:

Teams message on the teams channel:

After a trade is executed successfully, the employee makes appropriate entries to the the Trade Data app. In our next post we work on the third item: creating a Microsoft Power BI dashboard to view the trade data of Ctrade Inc.

Leave a Reply

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

*

code