When we have to associate the records we normally use AssociateRequest but while associating campaign with campaign related items such as Campaign, Marketing List, Product, or Salesliterature it doesn’t work.
For achieving this we have special Message made for Campaign called AddItemCampaignRequest.
Below we have provided the code that will associate the Campaign with Campaign Items.
//Add Item to Campaign
AddItemCampaignRequest req = new AddItemCampaignRequest();
// Specify the Campaign Id
req.CampaignId = new Guid(CampaignId)
// Specify the Logical name of the entity to which we want the Campaign to be associated
req.EntityName = entity.LogicalName;
// Specify the Id of the entity to which we want Campaign to be associated
req.EntityId = new Guid(EntityId)
// Execute the request
AddItemCampaignResponse resp = (AddItemCampaignResponse)_service.Execute(req);
We can associate Campaign, Marketing List, Product, or Salesliterature with the Campaign through the AddItemCampaignRequest message.
For achieving this we have special Message made for Campaign called AddItemCampaignRequest.
Below we have provided the code that will associate the Campaign with Campaign Items.
//Add Item to Campaign
AddItemCampaignRequest req = new AddItemCampaignRequest();
// Specify the Campaign Id
req.CampaignId = new Guid(CampaignId)
// Specify the Logical name of the entity to which we want the Campaign to be associated
req.EntityName = entity.LogicalName;
// Specify the Id of the entity to which we want Campaign to be associated
req.EntityId = new Guid(EntityId)
// Execute the request
AddItemCampaignResponse resp = (AddItemCampaignResponse)_service.Execute(req);
We can associate Campaign, Marketing List, Product, or Salesliterature with the Campaign through the AddItemCampaignRequest message.
To use this message, pass an instance of the AddItemCampaignRequest class as the request parameter in the Execute method. To perform this action, the caller must have access rights on the campaign entity instance.
Same we can associate the Campaign Activities with the Marketing Lists through the AddItemCampaignActivityRequest as given in the below code.
// Create the request object.
AddItemCampaignActivityRequest add = new AddItemCampaignActivityRequest();
// Set the properties of the request object.
add.CampaignActivityId = new Guid(CampaignActivityId);
// Specify the List Id to which we want Campaign Activity to be associated
add.ItemId = new Guid(listId);
// Specify the Logical name of the entity to which we want the Campaign Activity to be associated
add.EntityName = EntityName.list;
// Execute the request.
AddItemCampaignActivityResponse added = (AddItemCampaignActivityResponse) service.Execute(add);
The Marketing List being added must have already been added to the campaign otherwise error will be thrown and Marketing List will not be associated with Campaign Activities.
Hope this helps!!!
No comments:
Post a Comment