Answered by:
Updating 1 to Many records

Question
-
Hi guys,
I have an relationship setup between Opportunity and a custom entity.
I would like to update a field within the opporutnity and when I save the record, a field in all the related (child) records gets updated.
Is this possible using some fetch xml and/or jscript?
Thanks for any help
Bharat
- Moved by Tanguy T [MVP CRM]MVP, Moderator Thursday, October 13, 2011 1:19 PM code question (From:CRM)
Thursday, October 13, 2011 1:13 PM
Answers
-
It can be done using oData...
It still uses the same algorythm than above:
- Retrieve Id of the current record
- Retrieve all custom records linked to the current record
- Foreach custom record :
- Update the custom record
My blog : http://mscrmtools.blogspot.com
All my tools for Dynamics CRM 4.0 on my dedicated site: MSCRMTools Repository
Upgraded tools for Dynamics CRM 2011!
View Layout Replicator | Searchable Property Updater | Ribbon Browser | SiteMap Editor | JavaScript Web Resource Manager | Role updaterThursday, October 13, 2011 1:36 PMModerator -
Hello Bharat!
This is absolutely possible. I unfortunately don't have any examples at the moment but in CRM 4.0 we had many solutions that with a 1 to many relationship if the 1 had updates they were pushed automatically out to the Many. This was done through JScripting and Web service Calls. I believe the SDK and the CRM 2011 Training Kit would cover exactly what you need to do in this scenario. If I get a chance in a bit I'll find some references for you.
Psudo Code would be:
If Opportunity Entity fields were modified Then Get all custom entity records related to it from web service; Start Loop through each custom record at a time; Update Custom Entity fields; Use Webservice to update indivual record; Next;
Jason Cosman- Marked as answer by BharatP Friday, October 14, 2011 7:45 PM
Friday, October 14, 2011 1:35 AM
All replies
-
The easiest way seems to write a plugin with the following step:
- Retrieve Id of the current record
- Retrieve all custom records linked to the current record
- Foreach custom record :
- Update the custom record
My blog : http://mscrmtools.blogspot.com
All my tools for Dynamics CRM 4.0 on my dedicated site: MSCRMTools Repository
Upgraded tools for Dynamics CRM 2011!
View Layout Replicator | Searchable Property Updater | Ribbon Browser | SiteMap Editor | JavaScript Web Resource Manager | Role updaterThursday, October 13, 2011 1:19 PMModerator -
Hi again Tanguy,
As you well know Im not very fluent in C# so was hoping that it could be done in jscript?
Bharat
Thursday, October 13, 2011 1:30 PM -
It can be done using oData...
It still uses the same algorythm than above:
- Retrieve Id of the current record
- Retrieve all custom records linked to the current record
- Foreach custom record :
- Update the custom record
My blog : http://mscrmtools.blogspot.com
All my tools for Dynamics CRM 4.0 on my dedicated site: MSCRMTools Repository
Upgraded tools for Dynamics CRM 2011!
View Layout Replicator | Searchable Property Updater | Ribbon Browser | SiteMap Editor | JavaScript Web Resource Manager | Role updaterThursday, October 13, 2011 1:36 PMModerator -
Hello Bharat!
This is absolutely possible. I unfortunately don't have any examples at the moment but in CRM 4.0 we had many solutions that with a 1 to many relationship if the 1 had updates they were pushed automatically out to the Many. This was done through JScripting and Web service Calls. I believe the SDK and the CRM 2011 Training Kit would cover exactly what you need to do in this scenario. If I get a chance in a bit I'll find some references for you.
Psudo Code would be:
If Opportunity Entity fields were modified Then Get all custom entity records related to it from web service; Start Loop through each custom record at a time; Update Custom Entity fields; Use Webservice to update indivual record; Next;
Jason Cosman- Marked as answer by BharatP Friday, October 14, 2011 7:45 PM
Friday, October 14, 2011 1:35 AM -
Hi, I agree with Tanguy's approach via plug-in. It's the easiest and straight forward for what you are looking for. I would suggest that you look into the SDK samples. If it's only one record you may even get by with a workflow but I would highly recommend plug-in
- Proposed as answer by Seepath Sunday, October 16, 2011 3:44 PM
Sunday, October 16, 2011 3:42 PM