AddItem & RemoveItem Plugin Message‘gotchas’

When registering a Plug-In Step on the 'AddItem' and 'RemoveItem' messages I've found a couple of things to watch out for.

1. Missing InputParameters

When registering on Campaign Activity in response to adding a Marketing List, the InputParameters collection on the 'AddItem' step should contain the following:

  • EntityName = 'List' (String)
  • CampaignActivityId = <Id of the activity the list is being added to> (Guid)
  • ItemId = <Id of the list being added> (Guid)

However, when registering against the 'RemoveItem' message, watch out for the fact the 'EntityName' parameter is missing.

2. AddItem message fired even if item already is added.

When registering on Campaign Activity in response to adding a Marketing List, the AddItem message will fire each time the user selects 'Add from Campaign' even if the list already is associated with the Campaign Activity.

For this reason, you will need to check that the item is not already present to prevent your plugin from executing even when the item isn't actually being added:

 

bool listAllreadyAdded = (from l in serviceContext.CreateQuery<List>()
                                         join a in serviceContext.CreateQuery<CampaignActivityItem>()
                                           on l.ListId equals a.ItemId
                                         where a.CampaignActivityId.Id == activityId
                                         select true
                                        ).FirstOrDefault();

 

Comments are closed