Notifications
Announcements
No record found.
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
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
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.
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/
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.
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Tom_Gioielli 73 Super User 2025 Season 2
Gerardo RenterÃa Ga... 43 Most Valuable Professional
Daniyal Khaleel 32 Most Valuable Professional