private void ExecuteCrmAddresses(ExtendedPluginContext context) { // Account is used here, but since all Entities have the same exact field names, this works just fine var target = context.GetTarget <Entity>(); switch (target.LogicalName) { case Contact.EntityLogicalName: RemoveFormatting(target, Contact.Fields.Address3_Telephone1); RemoveFormatting(target, Contact.Fields.Address3_Telephone2); RemoveFormatting(target, Contact.Fields.Address3_Telephone3); RemoveFormatting(target, Contact.Fields.MobilePhone); break; case Lead.EntityLogicalName: case SystemUser.EntityLogicalName: RemoveFormatting(target, Contact.Fields.MobilePhone); break; } RemoveFormatting(target, Account.Fields.Address1_Telephone1); RemoveFormatting(target, Account.Fields.Address1_Telephone2); RemoveFormatting(target, Account.Fields.Address1_Telephone3); RemoveFormatting(target, Account.Fields.Address2_Telephone1); RemoveFormatting(target, Account.Fields.Address2_Telephone2); RemoveFormatting(target, Account.Fields.Address2_Telephone3); }
private void ExecuteCrmPhoneNumber(ExtendedPluginContext context) { // Account is used here, but since all Entities have the same exact field names, this works just fine var target = context.GetTarget <Entity>(); RemoveFormatting(target, Account.Fields.Telephone1); RemoveFormatting(target, Account.Fields.Telephone2); RemoveFormatting(target, Account.Fields.Telephone3); ExecuteCrmAddresses(context); }
protected override void ExecuteInternal(ExtendedPluginContext context) { // Get the Target var contact = context.GetTarget <Contact>(); if (string.IsNullOrWhiteSpace(contact.Address1_Line1)) { context.Trace(AddressNotUpdatedMessage); return; } using (var crm = new CrmContext(context.OrganizationService)) { var accounts = crm.AccountSet.Where(a => a.PrimaryContactId.Id == contact.Id); foreach (var account in accounts) { UpdateAccountAddress(context.OrganizationService, account.Id, contact); } } }