Quantcast
Channel: Forum CRM Development
Viewing all articles
Browse latest Browse all 1000

CRM 2011 Get Lookup Text Value

$
0
0

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);

       }

 

Viewing all articles
Browse latest Browse all 1000

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>