*This post is locked for comments
HI,
Write a code activity to fetch all the child records using query expression. Once you get all child records iterates through collection to update child record. Finally trigger your plugin on update of parent record. Make use of filtering attributes on Parent record name attribute or Option set attribute.
Thank you
Abhishek
If found useful, please mark the answer as verified
Hi ,
You need to get the entity id of the parent record in the plugin to retrieve the child records (use retrievemultiple message and pass fetchXML passing entity id ). Once you get the child record loop through the entity collection and using organization service update the child record.
public void Execute(IServiceProvider serviceProvider) { if (serviceProvider == null) throw new ArgumentNullException("serviceProvider"); var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); var serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); var service = serviceFactory.CreateOrganizationService(context.UserId); if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) { Entity targetAccount = (Entity)context.InputParameters["Target"]; if (targetAccount.Contains("telephone1")) { // Retrieve all contact for this account var fetch = @"<fetch no-lock='true' > <entity name='contact' > <attribute name='contactid'/> <filter> <condition attribute='parentcustomerid' operator='eq' value='{0}' /> </filter> </entity> </fetch>"; var fetchXML = string.Format(fetch, targetAccount.Id); var allContacts = service.RetrieveMultiple(new FetchExpression(fetchXML)).Entities; // Iterate through all contact record and update the phone number from account foreach (var contactEnt in allContacts) { Entity contactToUpdate = new Entity(contactEnt.LogicalName, contactEnt.Id); contactToUpdate["telephone1"] = targetAccount["telephone1"]; service.Update(contactToUpdate); } } } }
You have to follow below steps:
1.Register Plugin on message update and Entity will be parent record Entity.
2. Select fields in filter Attribute on which you want this plugin get execute.
3. In code, You have to fetch all children records of parent. (You will get parent record id from plugin Target)
.. You can use Flow without Coding. Fetch the Childs, loop and Update.
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 Abhilash Warrier as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
HR-09070029-0 2
UllrSki 2
ED-30091530-0 1