Answered by:
associate and disassociate contacts of an account using plugin

Question
-
Hi ,
I want to write a plugin on how to associate and disassociate contacts related to an account.
If there are any associated contacts then i want to disassociate them.. and if there are any disassociated records then i want to associated them to account...
Can anyone suggest a sample plugin to do this...
Thanks :)
Monday, June 16, 2014 9:57 AM
Answers
-
Hi,
Have a look here : http://lakshmanindian.wordpress.com/2012/10/28/programmatically-associate-and-disassociate-nn-relationship-records-in-microsoft-dynamics-crm-2011/
It explains association and disassociation of records.
- Proposed as answer by Mayank PujaraEditor Monday, June 16, 2014 10:32 AM
- Marked as answer by Amy.4 Monday, June 16, 2014 12:38 PM
Monday, June 16, 2014 10:03 AM
All replies
-
Hi,
Have a look here : http://lakshmanindian.wordpress.com/2012/10/28/programmatically-associate-and-disassociate-nn-relationship-records-in-microsoft-dynamics-crm-2011/
It explains association and disassociation of records.
- Proposed as answer by Mayank PujaraEditor Monday, June 16, 2014 10:32 AM
- Marked as answer by Amy.4 Monday, June 16, 2014 12:38 PM
Monday, June 16, 2014 10:03 AM -
Iam doing this through plugin registration tool... but unable to find the account entity if i give message as "associate"
.....
Iam also facing an issue with the code
It says the name "contact" does not exist in the current context.. how do i solve this issue..
Monday, June 16, 2014 11:48 AM -
Hi,
Answer to your first question: You're trying to associate/disassociate Account from Contact when a particular event occurs, right (like update, etc.)? You specify that event in Plugin Registration tool. If I am not wrong you do not want association to happen when an Account is disassociated from a Contact or vice versa, is it not?
Answer to your second question: The "contact" here is an EntityReference object, so you need to create that first. That EntityRefernce would ideally be the one you wish to associate/disassociate. Ideally an EntityReference object is created as follows:
EntityReference contact = new EntityReference("contact", new Guid("your_contact_id_here");
Monday, June 16, 2014 11:56 AM