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.