Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

Populate LookUp Field

(0) ShareShare
ReportReport
Posted on by 160

hi 

i have three tables(Given Below). i want to write a plugin on CREATE Message on Membership Table. when i create a record in "MEMBERSHIP" table, a record in "MEMBERSDETAILS" table will automatically created. can anyone please give a hint/idea, how i can do this

  • Suggested answer
    Bipin D365 Profile Picture
    28,961 Moderator on at
    RE: Populate LookUp Field

    Hi,

    You are setting Empty guid for contact lookup and that is why you get that error

    Add check condition as below before you map the field.

    if(contactId!=Guid.Empty)

    Map your look field

    Thanks,

    Bipin

  • happysingh0009 Profile Picture
    160 on at
    RE: Populate LookUp Field

    Exception Message: ReferencingEntity=tpamm_membershipmembers has attribute tpamm_members value=Guid.Empty for relationship=tpamm_MembershipMembers_Members_Contact, relationship.ReferencedEntity=contact, relationship.ReferencedAttribute.PlatformName=contactid

    I got this error this ur code.

  • Suggested answer
    Bipin D365 Profile Picture
    28,961 Moderator on at
    RE: Populate LookUp Field

    Hi,

    Try below code -

    Entity membershipDetails=new Entity("new_membershipdetails");

    membershipDetails["membershipid"]=new EntityReference("new_membership", membershipId);

    membershipDetails["contactid"]=new EntityReference("contact", contactid);

    service.Create(membershipDetails);

    membershipId -> You will get it from Target Entity

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • happysingh0009 Profile Picture
    160 on at
    RE: Populate LookUp Field

    Hi Sir

    Thank You for Reply :)

    i already read the contact table (it also have lookup inside membership table). But face problems in creating an object for member table.

  • Suggested answer
    Guido Preite Profile Picture
    54,077 Moderator on at
    RE: Populate LookUp Field

    the plugin needs to run in POST operation (usually synchronous) otherwise you will not have the ID of the membership you just created.

    Inside the plugin you read the Contact (I suppose there is a lookup pointing to Contact inside Membership) and after you create a new MemberDetails record filling the two lookups (one pointing to Membership with the ID you got and the other to Contact)

    Maybe this can be done also with a classic workflow but I usually write plugins in this scenario.

    hope it helps

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

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

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 293,278 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,002 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156 Moderator

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans