This documentation is archived and is not being maintained.

AddItemCampaignActivity Message (CrmService)

Forefront
banner art

[Applies to: Microsoft Dynamics CRM 4.0]

Find the latest SDK documentation: CRM 2015 SDK

Works for all deployment typesWorks online and offline

Adds an item to a campaign activity.

The relevant classes are specified in the following table.

TypeClass
RequestAddItemCampaignActivityRequest
ResponseAddItemCampaignActivityResponse
Entitycampaignactivity

Remarks

To use this message, pass an instance of the AddItemCampaignActivityRequest class as the request parameter in the Execute method.

To perform this action, the caller must have access rights on the entity instance specified in the request class. For a list of required privileges, see AddItemCampaignActivity Privileges.

Example

The following code example demonstrates how to add an item to a campaign activity.

[C#]
// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0; 
token.OrganizationName = "AdventureWorksCycle";
 
CrmService service = new CrmService();
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the request object.
AddItemCampaignActivityRequest add = new AddItemCampaignActivityRequest();

// Set the properties of the request object.
add.CampaignActivityId = new Guid("07D5B0B3-136C-48C6-8EAC-0030B9466E78");

// The item being added must have already been added to the campaign.
add.ItemId = new Guid("b4502053-6968-dc11-bb3a-0003ffbad8542");
add.EntityName = EntityName.salesliterature;

// Execute the request.
AddItemCampaignActivityResponse added = (AddItemCampaignActivityResponse) service.Execute(add); 
[Visual Basic .NET]
' Set up the CRM Service.
Dim token As New CrmAuthenticationToken()
' You can use enums.cs from the SDK\Helpers folder to get the enumeration for Active Directory authentication.
token.AuthenticationType = 0
token.OrganizationName = "AdventureWorksCycle";
 
Dim service As New CrmService()
service.Url = "http://<servername>:<port>/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials

' Create the request object.
Dim add As New AddItemCampaignActivityRequest()

' Set the properties of the request object.
add.CampaignActivityId = New Guid("07D5B0B3-136C-48C6-8EAC-0030B9466E78")

'The item being added must have already been added to the campaign.
add.ItemId = New Guid("b4502053-6968-dc11-bb3a-0003ffbad8542")
add.EntityName = EntityName.salesliterature

' Execute the request.
Dim added As AddItemCampaignActivityResponse = CType(service.Execute(add), AddItemCampaignActivityResponse)

See Also

Concepts

Reference


© 2010 Microsoft Corporation. All rights reserved.


Show: