Customer Engagement & Dynamics CRM Forum

Expand all | Collapse all

Set Lookup from text value in workflow

  • 1.  Set Lookup from text value in workflow

    TOP CONTRIBUTOR
    Posted 17 days ago
    I have a seemingly simple request, but it has proved very challenging! I have a lookup field on my contact record, that I would like to update using a workflow. When another field is populated with text, I need a workflow to find the corresponding record with that text value as its name, and then update the lookup field with that value.

    For example: A user enters a contact's address, including Address1: Country. I have a lookup field to an entity "new_country", that contains a list of all known countries. When the user enters the country in the text field, a workflow triggers that finds the country in the lookup table, and populates the lookup field.

    I've found this guide so far:
    Dynamics CRM (TCS Tools): Use a workflow to set a lookup
    Itaintboring remove preview
    Dynamics CRM (TCS Tools): Use a workflow to set a lookup
    It happens sometimes that we have a Parent and Child entities in Dynamics, and we need to link a child record to a parent record. Which seems to be a simple task unless, of course, we need to do it automatically.
    View this on Itaintboring >

    Unfortunately, when I install this solution it doesn't provide the steps stated in the guide, so I think this solution is a little broken at the moment (installed to an online environment, 9.1.0.25236). Does anyone have any other ideas on how this could be achieved?

    ------------------------------
    Tom Pickles
    Business Systems Developer
    Visit Scotland
    Edinburgh
    ------------------------------
    The first step toward cloud success. - Migrate from CRM to D365 with expert guidance from Microsoft. I'm Ready


  • 2.  RE: Set Lookup from text value in workflow

    SILVER CONTRIBUTOR
    Posted 16 days ago
    Tom,

    I have used Power Automate flows a ton to do this sort of thing several times before.  With lookups you have a slight problem that you could have several results returned and you need to tell the system which one to select (e.g. the first one) when this happens.  I love using Power Automate for this, but you will need to learn how to do OData filter queries, which is a bit different if you haven't done them before.

    You will want to grab the text field from the one record and then list the records of the related type.  Then you can add the filter in where it only returns records where the name equals the inputted value on the original record.  You will also want to restrict the results to the top 1 unless you want to add additional error handling.  Then when you grab the record id, you can use that to populate the relationship by the update record action, or (relate records if you use the current environment connector).

    Note:  If you update a lookup field in Power Automate, you need to use the following format to update the lookup.  It needs to know what entity you are "looking" up.

    plural entity name(record GUID)  OR   accounts(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx)

    ------------------------------
    Jonathan Blackham
    Sales Operations Specialist
    Valin Corporation
    ------------------------------

    The first step toward cloud success. - Migrate from CRM to D365 with expert guidance from Microsoft. I'm Ready


  • 3.  RE: Set Lookup from text value in workflow

    TOP CONTRIBUTOR
    Posted 16 days ago
    @Tom Pickles
    I have TCS Tools still running fine on​ my CRM; however, I do recall it being a little tricky to get running.
    Like @Jonathan Blackham says, Power Automate now makes this possible with the ​Common Data Service (current environment) List Records action.
    As it happens, the technique used here is very similar to how TCS Tools got over the text to lookup issue.
    You might also want to take a look at FetchXML Builder in XRM Toolbox - it makes getting the Filter Query and other bits a lot easier.​

    ------------------------------
    Donal McCarthy
    Digital Marketing Administrator
    BrightWork
    Galway
    ------------------------------

    The first step toward cloud success. - Migrate from CRM to D365 with expert guidance from Microsoft. I'm Ready


If you've found this thread useful, dive deeper into User Group community content by role