Delete message is not working to disassociate contacts from Marketing List table.
Loading
Delete message is not working to disassociate contacts from Marketing List table.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Allam PurushothamRank #715 · 3.3K reputationPosted Mar 5, 2024, 4:11 AM EST
Hi Prasad,
Plugin will not trigger for Delete Message, while disassociating the contact from Marketing List.
You need to register Plugin message with RemoveMember.
https://www.c-sharpcorner.com/article/trigger-a-plugin-when-contact-removed-form-marketing-list-entity/
Mithilesh TataRank #862 · 2.6K reputationPosted Mar 5, 2024, 3:47 AM EST
If the Delete message is not working for disassociating contacts from a Marketing List table, it's possible that there might be an issue with the plugin registration, the code logic, or the context in which the plugin is executing. Here are some troubleshooting steps you can follow:
Verify Plugin Registration:
Debugging Plugin Code:
Verify Plugin Execution Context:
Check Security Roles and Permissions:
Review Code Logic:
RemoveMemberFromListorDisassociate).Test Manually:
Consult Documentation and Community:
By following these steps and thoroughly investigating the potential causes of the issue, you should be able to identify and resolve any issues preventing the Delete message from correctly disassociating contacts from the Marketing List table.
fadece9 reputationPosted Mar 5, 2024, 4:10 AM EST
To delete a contact record from the Marketing List table using a plugin in a CMS development services Dubai scenario, follow these steps:
Kiran GiraseRank #3,637 · 402 reputationPosted Apr 23, 2024, 4:16 AM EDT
Hi,
To delete a contact record from the Marketing List table using a plugin in Dynamics 365, you need to write a custom plugin that triggers on the deletion of contact records and removes the corresponding record from the Marketing List table. Here's a general outline of how you can achieve this:
1.Create a Plugin: First, create a plugin assembly using Visual Studio or any other preferred development tool.
2.Register the Plugin: Register the plugin on the Delete event of the Contact entity.
3.Retrieve Marketing List Records: In your plugin code, retrieve the Marketing List records that contain the deleted contact. You can do this by querying the Marketing List entity using the contact's ID.
4.Remove Contact from Marketing List: Once you have retrieved the Marketing List records, remove the contact from each of these lists.
5.Update Marketing List Records: Update the Marketing List records in Dynamics 365 to reflect the removal of the contact.
Below the sample code,
using Microsoft.Xrm.Sdk; using Microsoft.Xrm.Sdk.Query; using System; namespace DeleteContactFromMarketingList { public class DeleteContactFromMarketingList : IPlugin { public void Execute(IServiceProvider serviceProvider) { IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext)); IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory)); IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId); if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity) { Entity entity = (Entity)context.InputParameters["Target"]; // Check if the deleted entity is a Contact if (entity.LogicalName == "contact") { Guid contactId = entity.Id; // Query to retrieve Marketing List records containing the deleted contact QueryExpression query = new QueryExpression("list"); query.ColumnSet = new ColumnSet("listid"); query.Criteria.AddCondition(new ConditionExpression("createdfromcode", ConditionOperator.Equal, 2)); // Marketing List created from Contacts query.LinkEntities.Add(new LinkEntity("list", "listmember", "listid", "listid", JoinOperator.Inner)); query.LinkEntities[0].LinkCriteria.AddCondition(new ConditionExpression("entityid", ConditionOperator.Equal, contactId)); EntityCollection marketingLists = service.RetrieveMultiple(query); // Remove contact from each Marketing List foreach (var list in marketingLists.Entities) { service.Delete("listmember", new Guid(list["listmemberid"].ToString())); } } } } } }