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

Friday, May 03, 2013

Create a Marketing Automation List

The following code example demonstrates how to create a Marketing Automation list and add a member to it.



   1:  //# [Create a Marketing Automation List ]

   2:  using System;

   3:  using CrmSdk;

   4:  using Microsoft.Crm.Sdk.Utility;

   5:   

   6:  namespace Microsoft.Crm.Sdk.HowTo

   7:  {

   8:        /// <summary>

   9:        /// Summary description for MarketingAutomationListCreation.

  10:        /// </summary>

  11:        public class MarketingAutomationListCreation

  12:        {

  13:              static void Main(string[] args)

  14:              {

  15:                    // TODO: Change the server URL and Organization to match your CRM Server and CRM Organization

  16:                    MarketingAutomationListCreation.Run("http://localhost:5555", "CRM_SDK");

  17:              }

  18:   

  19:              public static bool Run(string crmServerUrl, string orgName)

  20:              {

  21:                    // Set up the CRM Service.

  22:                    CrmService service = CrmServiceUtility.GetCrmService(crmServerUrl, orgName);

  23:                    

  24:                    #region Setup Data Required for this Sample

  25:                    account accountCreate = new account();

  26:                    accountCreate.name = "Fourth Coffee";

  27:                    accountCreate.description = "Coffee House";

  28:   

  29:                    Guid createdId = service.Create(accountCreate);

  30:                    #endregion

  31:   

  32:                    #region Create List

  33:   

  34:                    list autoList = new list();

  35:                    autoList.listname = "Test List";

  36:                    autoList.membertype = new CrmNumber();

  37:                    autoList.membertype.Value = 1;

  38:                    autoList.createdfromcode = new Picklist();

  39:                    autoList.createdfromcode.Value = 1;

  40:   

  41:                    Guid listId = service.Create(autoList);

  42:   

  43:                    #endregion

  44:   

  45:                    #region Add Member to List

  46:                    AddMemberListRequest addRequest = new AddMemberListRequest();

  47:                    addRequest.EntityId = createdId;

  48:                    addRequest.ListId = listId;

  49:   

  50:                    AddMemberListResponse response = (AddMemberListResponse) service.Execute(addRequest);

  51:                    #endregion

  52:   

  53:                    #region check success

  54:   

  55:                    bool success = false;

  56:   

  57:                    if (response.Id != Guid.Empty)

  58:                    {

  59:                          success = true;

  60:                    }

  61:                    #endregion

  62:              

  63:                    #region Remove Data Required for this Sample

  64:                    service.Delete(EntityName.account.ToString(), createdId);

  65:                    service.Delete(EntityName.list.ToString(), listId);

  66:                    #endregion

  67:   

  68:                    return success;

  69:              }

  70:        }

  71:  }

No comments: