Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 general forum

Unable to get lookup values

Posted on by Microsoft Employee

I have an entity named as Car, in this entity I have a contact lookup field where I can select contact.

Now my requirement to develop a plugin which will execute on Create at PreOperation Stage.

This plugin should get all the fields from contact entity of against selected contact.

Code which I tried so far

string fullname = ((EntityReference)entity["taqi_checkoutcontact"]).Name;

When I debug this code it give Name as null.

also I'm able to get values of all fields other then lookup

Can someone please help.

Categories:
  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Unable to get lookup values

    Thank you for your reply.

    I was able to get the value by query.

    Thanks

  • Suggested answer
    Kokulan Profile Picture
    Kokulan 18,048 on at
    RE: Unable to get lookup values

    Could you make sure, on the Check Out Contact record, the taqi_name field has value. if this is not set, you might get null.

    Instead of this : string fullname = ((EntityReference)entity["taqi_checkoutcontact"]).Name; you could try string fullname = entity[""].GetAttributeValue<EntityReference>("taqi_checkoutcontact").Name;

    If you are still having the issue after making sure the name field has value, you could actually query and get the value

    var ER= (EntityReference)entity["taqi_checkoutcontact"]);

    Entity entitydetails = service.Retrieve(ER.LogicalName,ER.Id, new ColumnSet("taqi_name"));

    string name =entitydetails.GetAttributeValue<String>("taqi_name");

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Unable to get lookup values

    Thanks Kokulan for your reply

    I just verified taqi_checkoutcontact is marked in select Attribute window

    1537.Capture.PNG

    But still using the above code, I'm getting NULL although I'm getting it's Id

    Thanks

  • Suggested answer
    Kokulan Profile Picture
    Kokulan 18,048 on at
    RE: Unable to get lookup values

    Hi

    Please make sure the taqi_checkoutcontact field is ticked in your entity image registration

    ScreenClip-_5B00_459_5D00_.png

    If it says all attributes then it should be passed, but if it lists few attributes, then you will have to select the contact lookup field as well for it to be passed to plugin

    ScreenClip-_5B00_459_5D00_.png

    You can check this using Plugin Registration tool

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

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans