To retreive the Guid of the Lookup entity

I have an entity which has 5 attributes. 1 of these attributes is a Lookup to another entity.

What I am trying to do with my Plugin is to retreive the Guid of the Lookup entity.

Entity entity = (Entity)context.InputParameters[“Target”];

if (entity.LogicalName == “new_producttaxrate”)

{

if (entity.Attributes.Contains(“new_product”))

{

 EntityReference ownerLookup = (EntityReference)entity.Attributes[“new_product”]; productName = ownerLookup.Name; Guid productId = ownerLookup.Id;

}

 }                                                                     (Or)

 

EntityReference customer = (EntityReference)(postImageEntity.Attributes[“customerid”]);

                                Guid GuidCustomerId = customer.Id;

                                string strTitle = postImageEntity.Attributes[“name”].ToString();// customer.Name;

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s