Skip to main content

Notifications

Microsoft Dynamics CRM forum
Suggested answer

Retrieve Customer field data in C#

Posted on by 524

Hi,

In a custom entity im having the customer lookup field, which can have account or contact record. In C#, how to retrieve the data from this customer lookup.

  • Suggested answer
    Abdul Wahab Profile Picture
    Abdul Wahab 12,070 Moderator on at
    RE: Retrieve Customer field data in C#

    Hi Anandhcrm,

    Yes, You are right. Here is the link for more details: Use multi-table lookup columns (Microsoft Dataverse) - Power Apps | Microsoft Learn.

    If I answer your question then please mark it as verified.

    Let me know if I can provide you with more details.

    Thanks
    Regards,

    Abdul Wahab
    Power Platform & Customer Engagement Developer/Lead/Solution Architecture/Project Manager
    Direct/WhatsApp:+923323281237
    E-mail: abdulwahabubit@outlook.com
    Skype: abdul.wahabubit
    Linkedin: www.linkedin.com/.../

  • Anandhcrm Profile Picture
    Anandhcrm 524 on at
    RE: Retrieve Customer field data in C#

    But customer lookup logical name is different when we creating rite.. so, it will be changing depends upon either account or contact record ? I am bit confusing.. can you please clarify me ?

  • Suggested answer
    Bipin D365 Profile Picture
    Bipin D365 28,962 Moderator on at
    RE: Retrieve Customer field data in C#

    Hi,

    Try below code

    EntityReference customerLookup=(EntityReference)targetEntity.Attributes["lookupfieldschemaname"];

    if(customerLookup.LogicalName=="account")

    {

    Entity accountRecord=service.Retrieve(customerLookup.LogicalName, customerLookup.Id, new ColumnSet("field1","field2");

    }

    else if(customerLookup.LogicalName=="contact")

    {

    Entity contactRecord=service.Retrieve(customerLookup.LogicalName, customerLookup.Id, new ColumnSet("field1","field2");

    }

  • Suggested answer
    Abdul Wahab Profile Picture
    Abdul Wahab 12,070 Moderator on at
    RE: Retrieve Customer field data in C#

    Hi Anandhcrm,

    What you are trying to write?

    1. Plugin
    2. Workflow extensions
    3. Console Application

    These links might be helpful:

    1. (+) retrieving records using plugin - Microsoft Dynamics CRM Forum Community Forum
    2. Write a plug-in (Microsoft Dataverse) - Power Apps | Microsoft Learn

    If I answer your question then please mark it as verified.

    Let me know if I can provide you with more details.

    Thanks
    Regards,

    Abdul Wahab
    Power Platform/Customer Engagement Developer/Lead/Solution Architecture/Project Manager
    Direct/WhatsApp:+923323281237
    E-mail: abdulwahabubit@outlook.com
    Skype: abdul.wahabubit
    Linkedin: www.linkedin.com/.../

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

Dynamics 365 Community Update – Sep 16th

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

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,522 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,441 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans