web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Integration with MailChimp

(0) ShareShare
ReportReport
Posted on by 12,119 Moderator

Hi all

I have below code which I write for some testing in c#.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net;
using System.IO;
using Newtonsoft.Json;

namespace TestForMailChimp
{
class Program
{
static void Main(string[] args)
{
var sampleList = JsonConvert.SerializeObject(
new
{
name = "Sample List",
contact = new
{
company = "MailChimp",
address1 = "675 Ponce De Leon Ave NE",
address2 = "Suite 5000",
city = "zip",
state = "GA",
zip = "30308",
country = "US",
phone = ""
},
permission_reminder = "You'\''re receiving this email because you signed up for updates about Freddie'\''s newest hats.",
campaign_defaults = new
{
from_name = "Freddie",
from_email = "freddie@freddiehats.com",
subject = "MailChimp Demo",
language = "en",
},
email_type_option = true
});
var uri = string.Format("https://{0}.api.mailchimp.com/3.0/lists", "");

try
{
using (var webClient = new WebClient())
{
webClient.Headers.Add("Accept", "application/json");
webClient.Headers.Add("Authorization", "apikey " + "ab15c4df98b952ca886a92e5a");

Console.WriteLine(webClient.UploadString(uri, "POST", sampleList));
}
}
catch (WebException we)
{
using (var sr = new StreamReader(we.Response.GetResponseStream()))
{
Console.WriteLine(sr.ReadToEnd());
}
}
}
}
}

I want to use this code on a custom button in crm. How can I use it.?

Thank you

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Andreas Cieslik Profile Picture
    9,267 on at

    Hi Abdul,

    You need ribbon workbench:

    ribbonworkbench.uservoice.com/.../80806-download-ribbon-workbench-for-crm-2011-2013-2015

    to create custom button and assign JavaScript to call custom workflow.

    Follow this guide:

    blogs.msdn.microsoft.com/.../how-to-execute-a-workflow-from-a-ribbon-button-and-control-when-the-button-is-enabled

    Sample plugin code with Webclient():

    msdn.microsoft.com/.../gg509030(v=crm.5).aspx

    Sample custom workflow:

    msdn.microsoft.com/.../gg334455(v=crm.5).aspx

    You need custom workflow activity with your MailChimp sample.

    With guide above you can call that workflow from your own ribbon button.

    Cheers,

    Andreas

  • Abdul Wahab Profile Picture
    12,119 Moderator on at

    Hi Andreas Cieslik

    I have my web client code which I convert it to custom work flow. Now I am able to see my custom work flow in CRM in the work flow add step. As mentioned in this thread community.dynamics.com/.../178014 call action but What may I call I do not have action in crm 2011?

    Thank you

  • Suggested answer
    Andreas Cieslik Profile Picture
    9,267 on at

    You need to call your workflow that uses your custom workflow activity as described here:

    blogs.msdn.microsoft.com/.../how-to-execute-a-workflow-from-a-ribbon-button-and-control-when-the-button-is-enabled

  • Abdul Wahab Profile Picture
    12,119 Moderator on at

    Hi Andreas Cieslik

    I make my custom work flow and add this custom work flow into crm through plug in registration tool and I add this custom work flow into work flow of crm with the help of add step and call this code on button click's event.

    function CallActionFromJavaScript() {

      debugger;

       //var entityId = Xrm.Page.data.entity.getId();;

       var entityName = "list";

       var requestName = "MailChimpIntegration Test";

       ExecuteActionCreateProject(/*entityId,*/ entityName, requestName);

    }

    function ExecuteActionCreateProject(/*EntityId,entityId,*/ entityName, requestName) {

       // Creating the request XML for calling the Action

       var requestXML = ""

       requestXML += "<s:Envelope xmlns:s=\"schemas.xmlsoap.org/.../envelope\">";

       requestXML += "  <s:Body>";

       requestXML += "    <Execute xmlns=\"schemas.microsoft.com/.../Services\" xmlns:i=\"www.w3.org/.../XMLSchema-instance\">";

       requestXML += "      <request xmlns:a=\"schemas.microsoft.com/.../Contracts\">";

       requestXML += "        <a:Parameters xmlns:b=\"schemas.datacontract.org/.../System.Collections.Generic\">";

       requestXML += "          <a:KeyValuePairOfstringanyType>";

       requestXML += "            <b:key>Target</b:key>";

       requestXML += "            <b:value i:type=\"a:EntityReference\">";

       //requestXML += "              <a:Id>"+entityId+"</a:Id>";

       //requestXML += "              <a:LogicalName>"+entityName+"</a:LogicalName>";

       requestXML += "              <a:Name i:nil=\"true\">";

       requestXML += "            </a:Name></b:value>";

       requestXML += "          </a:KeyValuePairOfstringanyType>";

       requestXML += "          <a:KeyValuePairOfstringanyType>";

       requestXML += "            <b:key>EntityId</b:key>";

       requestXML += "            <b:value i:type=\"c:string\" xmlns:c=\"www.w3.org/.../XMLSchema\"></b:value>";

       requestXML += "          </a:KeyValuePairOfstringanyType>";

       requestXML += "        </a:Parameters>";

       requestXML += "        <a:RequestId i:nil=\"true\">";

       requestXML += "         </a:RequestId>";

       requestXML += "        <a:RequestName>"+requestName+"</a:RequestName>";

       requestXML += "      </request>";

       requestXML += "    </Execute>";

       requestXML += "  </s:Body>";

       requestXML += "</s:Envelope>";

       var req = new XMLHttpRequest();

       req.open("POST", GetClientUrl(), false)

       req.setRequestHeader("Accept", "application/xml, text/xml, */*");

       req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");

       req.setRequestHeader("SOAPAction",     "schemas.microsoft.com/.../Execute&quot;);

       req.send(requestXML);

       //Get the Response from the CRM Execute method

       //var response = req.responseXML.xml;

       req.onerror = function (e) {

           alert(req.statusText);

       };

       if (req.status === 200) {

           alert(req.responseText);

       }

    }

    function GetClientUrl() {

       if (typeof Xrm.Page.context == "object") {

           clientUrl = Xrm.Page.context.getClientUrl();

       }

       var ServicePath = "/XRMServices/2011/Organization.svc/web";

       return clientUrl + ServicePath;

    }

    My code is not working by doing this all. When I run my code on visual studio. It is working and creating list. Where am I wrong please do let me know.

    Thank you

  • Suggested answer
    Alagunellaikumar Profile Picture
    6,212 on at

    You have to create a action and call your action through javascript

  • Abdul Wahab Profile Picture
    12,119 Moderator on at

    Hi all

    Is there anyway to info from custom workflow in crm.

    Thank You

  • Abdul Wahab Profile Picture
    12,119 Moderator on at

    Hi Alagu nellaikumar.S and Andreas Cieslik

    When I run my custom work flow I have this error.

    28885.3.png

    Please help me. How can I sole this problem?

    Thank You

  • Verified answer
    Community Member Profile Picture
    on at

    For this reference assembly error, you can check following link:

    https://blogs.msdn.microsoft.com/crm/2010/11/09/how-to-reference-assemblies-from-plug-ins/

     I tried below two solutions which work well for me:

    1. Use ILmerge tool to build the reference DLL into you workflow DLL.

    2. if your CRM are on premise, use Powershell to publish the reference DLL into the GAC of the server.

  • Verified answer
    Andreas Cieslik Profile Picture
    9,267 on at

    Hi Abdul,

    for all reference assemblies you use for your workflow DLL you need to use ILmerge tool.

    XrmToolKit offers support for that:

    xrmtoolkit.com/.../UsingILMerge

    as well as the great and free Visual Studio Developer Extensions for CRM:

    marketplace.visualstudio.com/items

    offers n ILmerge integration to very simple merge the DLL files

    Cheers,

    Andreas

  • Community Member Profile Picture
    on at

    Hello Abdul,

    You might want to consider a 3rd party CTI connector for that. One that I know of is Tenfold, they can integrate MS Dynamics. With their integration service you get features such as click to dial, call pop up, advanced analytics and a few more. You can check them out on the link below.

    www.tenfold.com/.../dynamics

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans