Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Suggested answer

Retrieve Customer field data in C#

(0) ShareShare
ReportReport
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 Super User 2024 Season 1 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,964 Super User 2024 Season 1 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 Super User 2024 Season 1 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

News and Announcements

Announcing Category Subscriptions!

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,370 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans