Answered by:
Need Help Writing Plug-In

Question
-
I need some help writing a pug-in to address the following:
We have a custom entity (A) that has a 1:N relationship with a child entity (B). Entity B has an Option Set field where one of the options is "Primary" diesignating that the B record thus designated ia the one and only B record that is "Primary" among its siblings.
To achieve this we need to assure that one and only one B record at a time is set as "Primary." This means that when the first B record is created, it must be marked as "Primary" and that if among multiple B records the users attempts to change a non-Primary record to "Primary," the previously designated "Primary" record must be changed to non-Primary so that two primary records do not exist at once.
This will be my first plug-in so I'm not too sure footed. I have read and re-read the SDK plug-in documentation, but it seems very short on information on how to obtain and use information from the Plug-in Data Context.
To accomplish the task, I will need to extract some information from the Context on idnetifying the Parent Record (A above) and Child record (B above). I think I probably need and EntityReference for the parent (A) so I can use it in a LINQ query (Where Clause) to walk the children and check which are currently set to Primary. I also need to know which child (B) record was just updated or created so I know which one the user intended to be the NEW primary.
If there is more (better) documentation on the contents of the Plug-in Data Context (especially the Input Parameters) that can help me I would appreciate the reference. Also if there are any code samples that are applicable to the above stated problem, I would love to look at those as well.
Thanks in advance.
Monday, June 11, 2012 4:25 PM
Answers
-
I don't have a whole solution as such.
The following blog will show you how to get a entity reference of entity a
http://www.mscrmshop.blogspot.com.au/2012/04/how-to-update-parent-record-when-child.html
you can have a look at the following blog to get all the records to belongs to a parent record and update them
http://www.mscrmshop.blogspot.com.au/2012/02/plugin-to-update-children-records-when.html
my blog also have some plugin tutorials for the beginers.
I hope this helps.
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Amreek Singh Senior CRM Consultant CDC Praxa Sydney, Australia http://mscrmshop.blogspot.com http://crm2011usersettings.codeplex.com
- Proposed as answer by Amreek Singh Tuesday, June 12, 2012 1:27 PM
- Marked as answer by Kahuna2000 Tuesday, June 12, 2012 2:19 PM
Tuesday, June 12, 2012 1:27 PM
All replies
-
Catch the create message of entity B, make sure there aren't any other primary B entities related to entity A
Something like that?
The SDK is packed full with samples, have a look at those :)
Monday, June 11, 2012 8:28 PM -
Hi Kahuna,
First refer SDK before you create plugin.Since you are going to make use of LINQ.I would suggest refer these blogs
1) http://blog.avtex.com/2011/05/14/using-linq-in-crm-2011-plugins/
2) http://crmconsultancy.wordpress.com/2010/10/25/plugins-in-crm-2011/
Regards,
- Edited by Mohammad Yusuf Ansari Tuesday, June 12, 2012 11:04 AM
Tuesday, June 12, 2012 11:02 AM -
I don't have a whole solution as such.
The following blog will show you how to get a entity reference of entity a
http://www.mscrmshop.blogspot.com.au/2012/04/how-to-update-parent-record-when-child.html
you can have a look at the following blog to get all the records to belongs to a parent record and update them
http://www.mscrmshop.blogspot.com.au/2012/02/plugin-to-update-children-records-when.html
my blog also have some plugin tutorials for the beginers.
I hope this helps.
If you find this post helpful then please "Vote as Helpful" and "Mark As Answer". Amreek Singh Senior CRM Consultant CDC Praxa Sydney, Australia http://mscrmshop.blogspot.com http://crm2011usersettings.codeplex.com
- Proposed as answer by Amreek Singh Tuesday, June 12, 2012 1:27 PM
- Marked as answer by Kahuna2000 Tuesday, June 12, 2012 2:19 PM
Tuesday, June 12, 2012 1:27 PM -
Thanks Amreek & Yusuf - very helpful references.
Sven, I had been through the SDK and only found 1 plugin project with 4 plug-ins in the assembly. They were helpful, but did not on point enough to help a newbie like me through the process. If there are other samples in the SDK that I'm not aware of, please LMK.
Tuesday, June 12, 2012 2:25 PM