web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

For workflows, is it possible to fill in a lookup field using another text field?

(0) ShareShare
ReportReport
Posted on by

Hi guys,

So for example, I'm working with a workflow where I would like it to do this:

If Company Name (free text) contains data, search for and fill in Parent Account (lookup).

So it will use the text in Company Name and look for it in Parent Account, if exact match found then fill in Parent Account.

From my understanding, this is not possible since you can only fill fields to a field of a same type or to a free text field. But fingers crossed there are some plugins or other solutions out there that can achieve this or help!

Thanks,

C

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mahadeo Matre Profile Picture
    17,021 on at

    You can create custome workflow activity  with one input parameter as company name..And text datatype..and in workflow activity you can search for company in account and set to appropriate field by passing output parameter from custom workflow active.

    Hope this will help. .

  • Community Member Profile Picture
    on at

    Hi Mahadeo - thanks for the response - could you please elaborate a bit more on this?

    Some more specific steps or external resources would be great please!

  • Royal King Profile Picture
    27,686 on at

    You are correct. There is no OOB that can match lookup record based on the display name. But you could write custom workflow step to return lookup value as output parameter based on the text input value. 

  • Pramod M Profile Picture
    1,445 on at

    Below please find the sample for creating custom workflow.

    community.dynamics.com/.../step-by-step-creating-custom-workflow-in-microsoft-crm-2011.aspx

    You can pass a the company text to this workflow, retrieve the account name from the company text and return the same.

    You can create a normal workflow call this custom workflow and assign the returned account to the lookup

  • Suggested answer
    PS Profile Picture
    23,577 on at

    Following URLs might help:

    blog.marksgroup.net/.../mscrm-2011-automatically-filling-name.html

  • Community Member Profile Picture
    on at

    Thanks guys,

    If I have no idea how to code, where should I start?

    Thanks,

    C

  • Verified answer
    Aileen Gusni Profile Picture
    44,524 on at

    Chon,

    You are right, you cannot get the lookup from a text field, CRM OOB function in workflow doesnt have functionality to search and match lookup field based on text.

    I understand your concern here you dont want to create another account from Lead after qualify, if you have this field value filled so it does mean you wont create new account after qualify, just create another Opportunity with existing Account.

    Her eis another similar question before (find Country by text is not possible)

    community.dynamics.com/.../128495.aspx

    Have you created plugin?

    If yes then let's start to another step.

    First of all, you need to retrieve the company Name (text) field from the lead.

    //Target Entity is Lead context

    if (TargetEntity.Contains("companyname")) //I forget the field name, but I think it is companyname

    {

        if (TargetEntity["companyname"].ToString() != string.Empty)

       {

              Account targetAccount = new Account(); //I use Early Bound here

               targetAccount = GetAccountInformationByNameBaseContext(baseContext, TargetEntity["companyname"].ToString());

              //then set back to the field you want.

              TargetEntity["parentaccountid"] = new EntityReference("account", targetAccount.AccountId.Id); //if the field name is parentaccountid

       }

    }

    If you use LINQ + Early Bound, it will be like this:

    //check and Get Account Info Id

           public account GetAccountInformationByNameBaseContext baseContext, string strName)

           {

               var accountInformation = from x in baseContext.AccountSet

                                     where x.name == strName

                                           select new account()

                                     {

                                         accountid = x.accountid,

                                     };

               if (accountInformation.ToList().Count > 0)

               {

                   return accountInformation.FirstOrDefault();

               }

               else

               {

                   return null;

               }

           }

    *sorry for typo error I dont use VS to write this query.

    If you dont use LINQ and not use Early Bound you can use Late Bound or You can also use Query Expression.

    msdn.microsoft.com/.../gg328300.aspx

    The concept here Chon, you need to query the data, find the Account Id to set back to your parent account field by keyword = the company name

    So the concept in SQL will be:

    select accountid from account

    where name = 'the company name here'

    You can achieve this either using LINQ or use Query Expresison or fetch XML

    msdn.microsoft.com/.../gg328149.aspx

    msdn.microsoft.com/.../gg328028.aspx

    msdn.microsoft.com/.../gg509028.aspx

    msdn.microsoft.com/.../hh210215.aspx (LINQ with Late Bound)

    msdn.microsoft.com/.../gg509026.aspx

    My other suggestion, you can do the same thing for Contact as well.

    Hope this help!

    Thanks.

  • Community Member Profile Picture
    on at

    Thanks for the responses guys,

    Aileen - I tried using the code you have written here but it doesn't let me compile. I have no idea when it comes to coding and I've just used msdn.microsoft.com/.../gg328515.aspx and a bit of copy and pasting to try get it work, but to no avail.

    Any nudges in the right direction would be appreciated!

    Cheers,

    C

  • Aileen Gusni Profile Picture
    44,524 on at

    Chon,

    Check this link to generate Early Bound

    https://msdn.microsoft.com/en-us/library/gg327844.aspx

    if you cannot find Account, Lead strong type

    and how to use

    https://msdn.microsoft.com/en-us/library/gg328499.aspx

    And refer to this to link to the how to create workflow activity, this is the very basic that must to know first before you go next step

    https://msdn.microsoft.com/en-us/library/gg328515.aspx

    https://msdn.microsoft.com/en-us/library/gg334455.aspx

    Thank you.

  • Abi Shende Profile Picture
    40 on at

    Chon,

    There is an add-on from North52 which will allow you to do this using a formula without coding.

    http://www.north52.com/

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans