web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
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

I have the same question (0)
  • Suggested answer
    Guido Preite Profile Picture
    54,086 Moderator on at

    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

  • happysingh0009 Profile Picture
    160 on at

    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
    Bipin D365 Profile Picture
    28,983 Moderator on at

    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

    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,983 Moderator on at

    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

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
ManoVerse Profile Picture

ManoVerse 197 Super User 2026 Season 1

#2
CU11031447-0 Profile Picture

CU11031447-0 100

#3
NeerajPawar Profile Picture

NeerajPawar 70

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans