public void UpdateSubContactInfos(IPluginContext context, IAccountService accountService) { #region Parameters check if (context == null) { throw new ArgumentNullException(nameof(context)); } if (accountService == null) { throw new ArgumentNullException(nameof(accountService)); } #endregion var account = context.GetInputParameter <Entity>(InputParameters.Target); var preImage = context.HasPreImage(PreImageName) ? context.GetPreImage(PreImageName) : null; var address1 = account.GetAttributeValue <string>(preImage, AccountDefinition.Columns.Address1_Line1); var address2 = account.GetAttributeValue <string>(preImage, AccountDefinition.Columns.Address1_Line2); ICollection <EntityReference> subContacts = accountService.GetSubContactRefs(account.ToEntityReference()); foreach (var contactRef in subContacts) { var updatedContact = contactRef.ToEntity(); updatedContact[ContactDefinition.Columns.Address1_Line1] = address1; updatedContact[ContactDefinition.Columns.Address1_Line2] = address2; accountService.Update(updatedContact, true); } }