Tag Cloud

CRM 2011 (161) CRM 4.0 (144) C# (116) JScript (109) Plugin (92) Registry (90) Techpedia (77) PyS60 (68) WScript (43) Plugin Message (31) Exploit (27) ShellCode (26) FAQ (22) JavaScript (21) Killer Codes (21) Hax (18) VB 6.0 (17) Commands (16) VBScript (16) Quotes (15) Turbo C++ (13) WMI (13) Security (11) 1337 (10) Tutorials (10) Asp.Net (9) Safe Boot (9) Python (8) Interview Questions (6) video (6) Ajax (5) VC++ (5) WebService (5) Workflow (5) Bat (4) Dorks (4) Sql Server (4) Aptitude (3) Picklist (3) Tweak (3) WCF (3) regex (3) Config (2) LINQ (2) PHP (2) Shell (2) Silverlight (2) TSql (2) flowchart (2) serialize (2) ASHX (1) CRM 4.0 Videos (1) Debug (1) FetchXml (1) GAC (1) General (1) Generics (1) HttpWebRequest (1) InputParameters (1) Lookup (1) Offline Plug-ins (1) OutputParameters (1) Plug-in Constructor (1) Protocol (1) RIA (1) Sharepoint (1) Walkthrough (1) Web.config (1) design patterns (1) generic (1) iframe (1) secure config (1) unsecure config (1) url (1)

Pages

Showing posts with label Plugin Message. Show all posts
Showing posts with label Plugin Message. Show all posts

Thursday, June 20, 2013

RetrievePrincipalAccess Message

Retrieves the access that the security principal (user) has for the specified entity instance.


//# The following code example shows how to use the RetrievePrincipalAccess message.

// 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://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the SecurityPrincipal object.
// This references the user whose access is being checked.
SecurityPrincipal principal = new SecurityPrincipal();

// Set the properties of th SecurityPrincipal object.
// Type is the typecode of the principalid.
principal.Type = SecurityPrincipalType.User;
// PrincipalId is the GUID of the user whose access is being checked.
principal.PrincipalId = new Guid("F111F0B1-70CE-44B4-8BF2-2E6C7EADA111");

// Create the target for the request.
TargetOwnedAccount owner = new TargetOwnedAccount();

// EntityId is the GUID of the account to which access is being checked.
owner.EntityId = new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");

// Create the request object.
RetrievePrincipalAccessRequest access = new RetrievePrincipalAccessRequest();

// Set the properties of the request object.
access.Principal = principal;
access.Target = owner;

// Execute the request.
RetrievePrincipalAccessResponse accessResponse = (RetrievePrincipalAccessResponse)service.Execute(access);




Saturday, June 08, 2013

LoseOpportunity Message

Sets the state of an opportunity to Lost.



//# The following code example shows how to use the LoseOpportunity message.
// 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://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

//Set up the data required for this sample.

// Create an account for the opportunity's potential customer.
account potentialCustomer = new account();
potentialCustomer.name = "Adventure Works Cycle";

Guid createdAccountId = service.Create(potentialCustomer);

// Build a query for US Dollar currency.
QueryByAttribute dollarQuery = new QueryByAttribute();
dollarQuery.EntityName = EntityName.transactioncurrency.ToString();
dollarQuery.Attributes = new string[] { "currencyname" };
dollarQuery.Values = new string[] { "US Dollar" };
// Be aware that using AllColumns may adversely affect
// performance and cause unwanted cascading in subsequent
// updates. A best practice is to retrieve the least amount of
// data required.
dollarQuery.ColumnSet = new AllColumns();

// Create the US currency request.
RetrieveMultipleRequest dollarRequest = new RetrieveMultipleRequest();
dollarRequest.Query = dollarQuery;

// Get US currency to use in the opportunity.
RetrieveMultipleResponse dollarResponse = (RetrieveMultipleResponse)service.Execute(dollarRequest);
transactioncurrency usCurrency = (transactioncurrency)dollarResponse.BusinessEntityCollection.BusinessEntities[0];

// Create an opportunity.
opportunity loseOpportunity = new opportunity();
loseOpportunity.customerid = new Customer();
loseOpportunity.customerid.type = EntityName.account.ToString();
loseOpportunity.customerid.Value = createdAccountId;
loseOpportunity.name = "SDK Sample for LoseOpportunity Message";
loseOpportunity.transactioncurrencyid = new Lookup();
loseOpportunity.transactioncurrencyid.type = EntityName.transactioncurrency.ToString();
loseOpportunity.transactioncurrencyid.Value = usCurrency.transactioncurrencyid.Value;

Guid loseOpportunityId = service.Create(loseOpportunity);

// Create an opportunityclose object.
opportunityclose oppClose = new opportunityclose();

// Set the opportunityclose properties.
oppClose.subject = "SDK Sample for LoseOpportunity Message";

// Set the opportunityid to an existing opportunity.
oppClose.opportunityid = new Lookup();
oppClose.opportunityid.type = EntityName.opportunity.ToString();
oppClose.opportunityid.Value = loseOpportunityId;

// Create the request.
LoseOpportunityRequest loseOppReq = new LoseOpportunityRequest();
loseOppReq.OpportunityClose = oppClose;

// A status of -1 will have the platform set the status to the appropriate value.
loseOppReq.Status = -1;

// Execute the request.
service.Execute(loseOppReq);




Friday, June 07, 2013

ImportCompressedAllXml Message

Import all customizations from an XML file that has been compressed using the WinZip format.



This request requires an ImportExportXml file for import. This example exports this file from CRM and then imports it back into Microsoft Dynamics CRM.
[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://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the request.
ExportCompressedAllXmlRequest requestExport = new ExportCompressedAllXmlRequest();
requestExport.EmbeddedFileName = "customizations.xml";

// Execute the request.
ExportCompressedAllXmlResponse responseExport = (ExportCompressedAllXmlResponse)service.Execute(requestExport);

// Get the compressed data
byte[] compressedXML = responseExport.ExportCompressedXml;

// Create the request.
ImportCompressedAllXmlRequest request = new ImportCompressedAllXmlRequest();

// Assign the compressed data
request.CompressedCustomizationXml = compressedXML;

// Execute the request.
ImportCompressedAllXmlResponse response = (ImportCompressedAllXmlResponse)service.Execute(request);




Thursday, June 06, 2013

ImportAllXml Message

Import all customizations from an XML file.

 
//# This request requires an ImportExportXml file for import. This example exports this file from CRM and then imports it back into Microsoft Dynamics CRM.

// 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://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// This is a potentially long running operation. The default 90-second
// time-out might be too short. Set the time-out to be 5 minutes.
// This property takes milliseconds.
service.Timeout = 300 * 1000;

// Create the request.
ExportAllXmlRequest request = new ExportAllXmlRequest();

// Execute the request.
ExportAllXmlResponse exportResponse = (ExportAllXmlResponse)service.Execute((Request)request);

// Create the request.
ImportAllXmlRequest importRequest = new ImportAllXmlRequest();

// Tell the request where the temporary XML file is located.
importRequest.CustomizationXml = exportResponse.ExportXml;

// Execute the import.
ImportAllXmlResponse importResponse = (ImportAllXmlResponse)service.Execute(importRequest);




Saturday, June 01, 2013

Clone Message

Copies an existing contract and its line items.



//# The following code example demonstrates how to clone a contract.
// 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://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the request object.
CloneContractRequest clone = new CloneContractRequest();

// Set the properties of the request object.
clone.ContractId = new Guid("C15AF217-C17E-DA11-B90F-000874DE7397");
clone.IncludeCanceledLines = false;
clone.ReturnDynamicEntities = false;

// Execute the request.
CloneContractResponse cloned = (CloneContractResponse) service.Execute(clone);




Wednesday, May 29, 2013

RevokeAccess Message

Revokes access rights to the entity instance for the specified security principal (user or team).

Remarks

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

This method also applies to all child instances of the target instance. For all child instances, if the caller does not have share privileges for those entity types or share rights to the instances, access to the child instances is not revoked. As a result, the owner of the instance or a user who shares the instance with share rights automatically has share rights to all child instances of the target instance. In this case, only the lack of privileges to a particular entity type prevents access to the child instances from being revoked.

For a description of how actions on a parent instance affect child instances, see Cascading Rules.

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 RevokeAccess Privileges.

 
//#The following code example shows how to use the RevokeAccess message.

// 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://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the SecurityPrincipal.
SecurityPrincipal principal = new SecurityPrincipal();
principal.Type = SecurityPrincipalType.User;

// PrincipalId is the GUID of the user whose access is being revoked.
principal.PrincipalId = new Guid("7B222F98-F48A-4AED-9D09-77A19CB6EE82");

// Create the target for the request.
TargetOwnedAccount target = new TargetOwnedAccount();

// EntityId is the GUID of the account to which access is being revoked.
target.EntityId = new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");

// Create the request object.
RevokeAccessRequest revoke = new RevokeAccessRequest();

// Set the properties of the request object.
revoke.Revokee = principal;
revoke.Target = target;

// Execute the request.
RevokeAccessResponse revoked = (RevokeAccessResponse)service.Execute(revoke);





Monday, May 27, 2013

Cancel Message

Cancels a contract or salesorder

    //#Cancels a Contract
// 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://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the cancel request for a previously created contract
CancelContractRequest contactCancelationRequest = new CancelContractRequest();

// Set the properties for the request
contactCancelationRequest.ContractId = new Guid("C15AF217-C17E-DA11-B90F-000874DE7397");
contactCancelationRequest.CancelDate = new CrmDateTime();
contactCancelationRequest.CancelDate.Value = DateTime.Now.ToString();
contactCancelationRequest.Status = 5;

// Execute the request
service.Execute(contactCancelationRequest);




The following code example demonstrates how to cancel a sales order.

 
//# cancel a sales order.
// 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://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the order close activity object.
orderclose close = new orderclose();

// Set the properties of the order close object.
close.subject = "orderclose";

// Create a Lookup for the sales order being canceled.
close.salesorderid = new Lookup();
close.salesorderid.type = EntityName.salesorder.ToString();
close.salesorderid.Value = created.id;

// Create the request object.
CancelSalesOrderRequest cancel = new CancelSalesOrderRequest();

// Set the properties of the request object.
cancel.OrderClose = close;
cancel.Status = -1;

// Execute the request.
CancelSalesOrderResponse canceled = (CancelSalesOrderResponse) service.Execute(cancel);




Saturday, May 25, 2013

Book Message

Schedules or "books" an appointment.




//# The following example shows how to use the Book message to schedule an appointment.
// 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://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the activityparty entity instance.
activityparty party = new activityparty();
party.scheduledstart = new CrmDateTime();
party.scheduledstart.Value = DateTime.Now.AddHours(1).ToString();
party.scheduledend = new CrmDateTime();
party.scheduledend.Value = DateTime.Now.AddHours(2).ToString();
party.partyid = new Lookup();
party.partyid.type = EntityName.systemuser.ToString();
party.partyid.Value = user.UserId;

// Create the appointment entity instance.
appointment appointment = new appointment();

// Set the appointment's properties.
appointment.description = "This is a test of the book message.";
appointment.scheduledstart = new CrmDateTime();
appointment.scheduledstart.Value = DateTime.Now.AddHours(1).ToString();
appointment.scheduledend = new CrmDateTime();
appointment.scheduledend.Value = DateTime.Now.AddHours(2).ToString();
appointment.location = "Office";
appointment.subject = "Testing book appointment";
appointment.requiredattendees = new activityparty[] {party};
appointment.statecode = new AppointmentStateInfo();
appointment.statecode.Value = AppointmentState.Open;
appointment.statuscode = new Status();
// This is the default value.
appointment.statuscode.Value = -1;

// Create the target.
TargetScheduleAppointment target = new TargetScheduleAppointment();

// Set the target properties.
target.Appointment = appointment;

// Create the request.
BookRequest book = new BookRequest();

// Set the request properties.
book.Target = target;

// Execute the request.
BookResponse booked = (BookResponse)service.Execute(book);



BackgroundSendEmail Message



//# Sends an e-mail asynchronously.
// 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://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create a query for the BackgroundSendEmailRequest object that will find all
// e-mails with the text "SDK Sample E-mail" in the subject and a status code of
// "Pending Send".

// NOTE: A more robust query would include e-mails that have been downloaded
// previously but not sent for some reason and exclude emails that have failed
// delivery too many times.

// Create the condition for e-mail subject text.
ConditionExpression subjectCondition = new ConditionExpression();
subjectCondition.AttributeName = "subject";
subjectCondition.Operator = ConditionOperator.Like;
subjectCondition.Values = new string[] { "SDK Sample Email%" };

// Create the condition for e-mail status. Only draft e-mails will be sent.
ConditionExpression statusCondition = new ConditionExpression();
statusCondition.AttributeName = "statuscode";
statusCondition.Operator = ConditionOperator.Equal;
statusCondition.Values = new object[] { EmailStatus.PendingSend };

// Create the query filter.
FilterExpression emailFilter = new FilterExpression();
emailFilter.Conditions = new ConditionExpression[] { statusCondition };
emailFilter.FilterOperator = LogicalOperator.And;

// Query for e-mail activity to send.
QueryExpression emailsQuery = new QueryExpression();
// Be aware that using AllColumns may adversely affect
// performance and cause unwanted cascading in subsequent
// updates. A best practice is to retrieve the least amount of
// data required.
emailsQuery.ColumnSet = new AllColumns();
emailsQuery.EntityName = EntityName.email.ToString();
emailsQuery.Criteria = emailFilter;

// Create the request.
BackgroundSendEmailRequest bkgrndSendEmailRequest = new BackgroundSendEmailRequest();

// Set the query.
bkgrndSendEmailRequest.Query = emailsQuery;

// Execute the request. This will change the status from "Pending Send" to "Sending".
BackgroundSendEmailResponse bkgrndSendEmailResponse = (BackgroundSendEmailResponse)service.Execute(bkgrndSendEmailRequest);

foreach (email emailRecordToProcess in bkgrndSendEmailResponse.BusinessEntityCollection.BusinessEntities)
{
// Use SMTP or MAPI to compose actual emails and submit them for delivery.
}




Friday, May 24, 2013

Assign Message

Assigns the specified entity instance to a new security principal (user). This changes the ownerid attribute of the instance.



//# The following code example demonstrates how to assign the specified entity instance to a new security principal (user).

// 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://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the SecurityPrincipal object.
SecurityPrincipal assignee = new SecurityPrincipal();
assignee.Type = SecurityPrincipalType.User;

// PrincipalId is some known Guid belonging to the user or team that will own this record.
assignee.PrincipalId = new Guid("326A0053-71CB-465E-9BEB-633E2E0851A9");

// Create the target object for the request.
TargetOwnedAccount target = new TargetOwnedAccount();

// Set the properties of the target object.
// EntityId is some known Guid belonging to the account that is being assigned to the user.
target.EntityId = new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");

// Create the request object.
AssignRequest assign = new AssignRequest();

// Set the properties of the request object.
assign.Assignee = assignee;
assign.Target = target;

// Execute the request.
AssignResponse assignResponse = (AssignResponse)service.Execute(assign);




Thursday, May 23, 2013

SetStateAccount Message

Sets the state of an account.



//# The following code example shows how to use the SetStateAccount message.

// 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://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the request object.
SetStateAccountRequest state = new SetStateAccountRequest();

// Set the properties of the request object.
state.AccountState = AccountState.Inactive;
state.AccountStatus = 2;

// EntityId is the GUID of the account whose state is being changed.
state.EntityId = new Guid("AD618DB2-F0DB-4A6A-8C4B-2F2213EAA38E");;

// Execute the request.
SetStateAccountResponse stateSet = (SetStateAccountResponse)service.Execute(state);





AddMembers



//The following code example demonstrates how to add a set of users to a team.
// 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://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the AddMembersTeamRequest object.
AddMembersTeamRequest addRequest = new AddMembersTeamRequest();

// Set the AddMembersTeamRequest TeamID property to the object ID of
// an existing team.
addRequest.TeamId = new Guid("9AF74EF9-A04C-DA11-A0C5-000D9DD8CDAC");

// Set the AddMembersTeamRequest MemberIds property to an
// array of GUIDs that contains the object IDs of one or more system users.
addRequest.MemberIds = new Guid[] {new Guid("A0F2D8FE-6468-DA11-B748-000D9DD8CDAC")};

// Execute the request.
AddMembersTeamResponse addResponse = (AddMembersTeamResponse)service.Execute(addRequest);




AddMember

Adds a member to a list. The member added must be one of the following entity types: account, contact, or lead.

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

To perform this action, the caller must have access rights on the list (marketing list) entity instance. For a list of required privileges, seeAddMemberList Privileges.



//# The following code example demonstrates how to add a member to a list.
// 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://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

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

// Set the properties of the request object.
add.EntityId = new Guid("b050f053-yur3-dc31-bb3a-0003ffbad37a");
add.ListId = new Guid("C15AF217-C17E-DA11-B90F-000874DE7397");

// Execute the request.
AddMemberListResponse added = (AddMemberListResponse) service.Execute(add);




Wednesday, May 22, 2013

Retrieve Message

Retrieves a business entity instance with the specified ID.

Remarks

To use this message, pass an instance of the RetrieveRequest class as the request parameter in the Execute method. If the columnset includes attributes that are not valid for retrieve, they will be ignored. 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 Retrieve Privileges.

For better performance, use the Retrieve method instead of using this message.

   

//# The following code example shows how to use the Retrieve message.

// 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://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the column set object that indicates the fields to be retrieved.
ColumnSet cols = new ColumnSet();

// Set the properties of the column set.
cols.Attributes = new string [] {"name"};

// Create the target object for the request.
TargetRetrieveAccount target = new TargetRetrieveAccount();

// Set the properties of the target object.
// EntityId is the GUID of the record being retrieved.
target.EntityId = new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");

// Create the request object.
RetrieveRequest retrieve = new RetrieveRequest();

// Set the properties of the request object.
retrieve.Target = target;
retrieve.ColumnSet = cols;

// Execute the request.
RetrieveResponse retrieved = (RetrieveResponse)service.Execute(retrieve);




AddItem Plugin Message (Campaign)

Adds an item to a campaign. The item added must be one of the following entity types: campaign, list, product, or salesliterature.

The relevant classes are specified in the following table.

Type                         Class

Request                     AddItemCampaignRequest

Response                  AddItemCampaignResponse

Entity                          campaign

Optional Parameters   RequestIdOptionalParameter

Remarks

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. For a list of required privileges, seeAddItemCampaign Privileges.

  

//The following code example demonstrates how to add an item to a campaign.
// Set up the CRM Service.
CrmAuthenticationToken token = new CrmAuthenticationToken();
// You can use enums.cs from the SDK\Helpers folder to get the enumeration.
token.AuthenticationType = 0;
token.OrganizationName = "AdventureWorksCycle";

CrmService service = new CrmService();
service.Url = "http://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

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

// Set the properties of the request object.
add.CampaignId = new Guid("b4502053-6968-dc11-bb3a-0003ffbad8542");
add.EntityId = new Guid("b050f053-yur3-dc31-bb3a-0003ffbad37a");
add.EntityName = EntityName.product;
// Execute the request.
AddItemCampaignResponse added = (AddItemCampaignResponse)service.Execute(add);




Saturday, May 18, 2013

RemoveItemCampaign Message

Removes an item from a campaign.


//# The following code example shows how to use the RemoveItemCampaign message.

// 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://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the request object.
RemoveItemCampaignRequest remove = new RemoveItemCampaignRequest();

// Set the ID of the campaign.
remove.CampaignId = new Guid("d7f33457-660e-de11-bf40-00155da4c706");

// Set the ID of the campaign item to remove.
remove.EntityId = new Guid("6e47aeb7-c30d-de11-bf40-00155da4c706");

// Execute the request.
RemoveItemCampaignResponse removed =
(RemoveItemCampaignResponse)service.Execute(remove);




Friday, May 17, 2013

RemoveMemberList Message

Removes a member from a list.



//# The following code example shows how to use the RemoveMemberList message.

// 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://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the request object.
RemoveMemberListRequest remove = new RemoveMemberListRequest();

// Set the ID of the list.
remove.ListId = new Guid("18ECA720-493E-4800-BBFD-638BD54EB325");
// Set the ID of the list item to remove.
remove.EntityId = new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");

// Execute the request.
RemoveMemberListResponse removed = (RemoveMemberListResponse)service.Execute(remove);




Thursday, May 16, 2013

PublishXml Message

Publish the customizations for the specified entities.

   
//# The following code example shows how to use the PublishXml message.

// 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://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the request.
PublishXmlRequest request = new PublishXmlRequest();

request.ParameterXml = @"<importexportxml>
<entities>
<entity>account</entity>
<entity>contact</entity>
</entities>
<nodes />
<securityroles />
<settings />
<workflows />
</importexportxml>";

// Execute the request.
PublishXmlResponse response = (PublishXmlResponse)service.Execute(request);




Sunday, May 12, 2013

Merge Message

Merges the information from two entity instances of the same type.



//# The following code example shows how to use the Merge message.

// 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://:/mscrmservices/2007/crmservice.asmx";
service.CrmAuthenticationTokenValue = token;
service.Credentials = System.Net.CredentialCache.DefaultCredentials;

// Create the target for the request.
TargetMergeAccount target = new TargetMergeAccount();
// EntityId is the GUID of the account that is being merged into.
target.EntityId = new Guid("2B951FBC-1C56-4430-B23B-20A1349068F3");

// Create the request.
MergeRequest merge = new MergeRequest();
// SubordinateId is the GUID of the account merging.
merge.SubordinateId = new Guid("AD618DB2-F0DB-4A6A-8C4B-2F2213EAA38E");
merge.Target = target;
merge.PerformParentingChecks = false;

account updateContent = new account();
updateContent.address1_line1 = "test";
merge.UpdateContent = updateContent;


// Execute the request.
MergeResponse merged = (MergeResponse)service.Execute(merge);




Sunday, May 05, 2013

AddItem Plugin Message(CampaignActivity)

Adds an item to a campaign activity.

The relevant classes are specified in the following table.

Type                 Class

Request            AddItemCampaignActivityRequest

Response         AddItemCampaignActivityResponse

Entity               campaignactivity

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.

  
//# The following code example demonstrates how to add an item to a campaign activity.
// 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://:/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);