How to update Lookup field for entity using Microsoft Power Automate Flow.

Hello Guys,

In our previous blog we have seen Bing Maps and Power Automate Flow. Today we are going to see how to update lookup field for entity using MS Flow.



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.

Consider a scenario where we have two entity named Account and Contact. Both these entity is having one common lookup field named country which you can see in below image:




Now as we know this both entity are related as parent-child, whenever we are creating a new record for contact the country of account(Company on contact) should be copied or updated on contact entity. We can achieve this using power automate flow. We will be creating a flow which will run on create and will update country in contact.






As you can see in above image, we have already created the flow and updating the country field with account's country value. This flow will run and update contact as you can see in below example where we have created new contact.





Consider a scenario where country field's value is not present on account entity. So in this situation our flow will run or not? let's check.

We are creating another contact with different account where country lookup is not available on account.





Now if we check flow run history then we will see, our flow got failed as country lookup is null.




To resolve this we can make the country field as requirement field on account so that whenever a new account will be created, it will have country field value and our flow will run properly. But what if we want country field as optional? In this situation our flow will get failed again.

To resolve this we need to do some changes and have to use expression as shown below:




if(empty(outputs('Account')?['body/_blg_country_value']),null,concat('/blg_countries(',outputs('Account')?['body/_blg_country_value'],')'))

Now try to create a new contact and check whether this flow is failing or not.

Hope it helps...

Comments

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.