We have many times faced this scenario; of updating a lookup field from a text field. I will be showing you how to do this without writing a single line of code, with the help of MS Flows.
Scenario: I have a custom entity ‘geography’ where I am storing all my post codes. This custom entity is also related to users/Salesperson. On my contact form there’s a reference field of Geography (Lookup) and Text field is Address 1: ZIP/Post Code. Now based on what is filled in the text post code field, I want to auto-populate geography so that I can further use it for salesperson assignment.
Let’s see how we can achieve this:
Step 1: Log on to flows.microsoft.com
Step 2: Click ‘My Flows’
Step 3: Click new and create from blank
Step 4: Select a trigger for your flow to execute
Step 5: Select the instance/Org of CRM and specify the entity
Step 6: Click on new step and select ‘condition’
I have entered a condition as ‘if Address 1 ZIP/Post code contains data’
Step 7: After you have entered condition, automatically a Yes and No branch will pop up. Under the Yes branch select what would you like to find. Basically asking flow to look at the list of geographies (custom entity for post code) to find if the Address 1: ZIP/Post code entered is found in the list. That’s why I have selected list records
Step 8: Specify the instance, entity and ODATA query. In my case the query is “name of the geography is equal to Address1:ZIP/Post code”. I know it sounds like a code but its not. You just have to know schema name of the field of the records you want to list. e.g. name eq ‘Address1:ZIP/Post Code’
Note that eq means equal. And I am using Address 1:ZIP/Post code as a dynamic expression and not query.
Now click on update a record
Step 10: Again select the instance, entity name and unique identifier of record. In my case ‘contact’
Step 11: The end result should be as shown below. Now click save and test your flow.
This is absolutely amazing coz we don’t need code to do that anymore now.
Hope this helps.