Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Blogs / CleverAX / How to build a PowerApp tha...

How to build a PowerApp that generates product labels. Part 2: Use Microsoft Flow to get data from MSDyn365FO

In the previous post we created a PowerApp that generates product label based on the information entered manually in the app fields. In this post we will enhance the app to extract Product name and Origin values from MSDyn365FO based on the Item number, i.e. rather than populating all tree fields manually we will enter only Item number. To make this work we will need a help from Microsoft Flow.

Let’s go to https://flow.microsoft.com/ and create a new flow:

ZPLAPP_MSFlow

We will add PowerApp as a trigger and use “Get record” to extract the data from MSDyn365FO. Then we should specify connection to our MSDyn365FO instance and data entity name that we will use to get the data from the system. In this example I will use ReleasedDistincProductV2 to get Product search name and Origin of the item.

Since ReleasedDistincProductV2 entity uses Legal entity and Item number field as a key we should specify it in the “Object Id” property. In this case I have hardcoded Legal entity name and also added Getrecord_Object_Id that represents the value passed from the PowerApp.

In the response we map output variables with entity fields that “Get record” returns (i.e. ProductSeachName and Country/Region of Origin.

Flow templte looks as follows:

ZPLAPP_MSFlowTemplate

Let’s test the Flow to verify that it returns correct information:

ZPLAPP_TestMSFlowTemplate

Click “Save & Test” and enter Item number that exists in MSDyn365FO:

ZPLAPP_RunMSFlow

Click “Run flow” gives:

ZPLAPP_FlowStarted

After MS Flow configuration is completed we need to modify PowerApp to use it. As you remember, we are going to trigger MS Flow when the Item number field value is changed. Therefore, we should select Item number text input field and for the “OnChange” action click on the “Flows” button:

ZPLAPP_AddFlowtoPowerApp

In the Opened form select the Flow that we previously created:

ZPLAPP_AssosiateFlowDialog

After that you will notice that “OnChange” expression has been prepopulated automatically to call the Flow selected. Now, we need to modify it to pass the value from Item number text input field to the Flow and save the result returned by the Flow to the variable. The final expression looks like:

Set(FlowValues,'PowerApp->Getarecord,RespondtoPowerApps'.Run(ItemId.Text))

Where ‘PowerApp->Getarecord,RespondtoPowerApps’.Run(ItemId.Text) executes the Flow. Function “Run” accepts parameter value that is passed to the Flow (value from Item number text box). Function “Set” is used to set “FlowValues” variable with the result of Flow execution. More information on set function could be found here.

ZPLAPP_SetFlowVariable

Next step is to set Product name and Origin fields with the values returned by the Flow:

ZPLAPP_SetValuesFromFlowVariableProductSearchName

ZPLAPP_SetValuesFromFlowVariable_COO

Done. If we run the app we would get the following result:

ZPLAPP_Part2Final

To summarize: In this post we have created Microsoft Flow that gets the data from MSDyn365FO, then we have modified the app to pass Item number information to the Flow and automatically populates Product name and Origin with the data from the system.

In the next post we will embed our PowerApp in Dyamics 365 for Finance and Operations to the Released products form and will pass Item number from the record selected in the grid to the app.


This was originally posted here.

Comments

*This post is locked for comments