Dear All,
I wrote a plugin. I am trying to create account category record after creating account where I need one lookup Guid and the Text Value. I am getting Guid value. But lookup text value also i need to retrieve. How to get this text value ? I wrote the following
code getting error on the bold line. Kindly help me.
Entity account = context.InputParameters["Target"] as Entity;
Guid accountid = (Guid)context.OutputParameters["id"];
EntityReference PrimCategory = account.Attributes["new_primarycategoryid"] as EntityReference;
if (account.Attributes.Contains("new_primarycategoryid") && (accountid != null))
{
Entity AccCategory = new Entity("new_accountcategory");
AccCategory.Attributes = new AttributeCollection();
AccCategory.Attributes.Add("new_name", ((EntityReference)PrimCategory).Name);
AccCategory.Attributes.Add("new_accountid", new EntityReference("account", accountid));
AccCategory.Attributes.Add("new_accountareaofbusinessid", new EntityReference("new_primarycategoryid", PrimCategory.Id));
service.Create(AccCategory);
}