Hi all
I have this code
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", "us14");
try
{
using (var webClient = new WebClient())
{
webClient.Headers.Add("Accept", "application/json");
webClient.Headers.Add("Authorization", "apikey " + "ab15c4d132d2aff98b952ca886a92e5a");
Console.WriteLine(webClient.UploadString(uri, "POST", sampleList));
}
}
catch (WebException we)
{
using (var sr = new StreamReader(we.Response.GetResponseStream()))
{
Console.WriteLine(sr.ReadToEnd());
}
}
}
}
}
I want custom workflow for this code. I want this because of my this requirement.
Please do let me know What can I do to solve my problem?
Thank you
*This post is locked for comments
Hi guys! You can look at our CTI solution, Tenfold. We integrate MS Dynamics for a more productive sales workflow. Check out the features of a Tenfold integration here: www.tenfold.com/.../dynamics
Obviously it means what it means. CRM can't load mentioned assembly. If you want to use that assembly you will have to combine all your assemblies into one using ILmerge - nicknow.net/dynamics-crm-ilmerge-dll-plugin or use .Net inbuilt assemblies for serialization/deserialization purposes like System.Runtime.Serialization.Json
Good luck.
Hi Andrii Butenko
When I run my custom work flow from crm. I have this error. Please help How can I resiolve this issue.
Thank you
Looks like you were able to convert your console app to Custom Workflow Activity that was the main goal of this thread.
Anyway if you want to fix your next issue you should understand that you are trying to use CRM 4.0 endpoint. Based on your syntax I can assume that you use 2011 or higher that leads to following article that describes how to call workflow from JS with 2011 endpoints - www.mscrmconsultant.com/.../execute-workflow-using-javascript-in.html
Hi Andrii Butenko
Sorry for disturbing you. I wrote this code to convert my web client to custom work flow
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;
using System.Net;
using System.IO;
using Newtonsoft.Json;
namespace IntegrateMailChimpWithCRMTest
{
public class MailChimpTest : CodeActivity
{
protected override void Execute(CodeActivityContext context)
{
ITracingService tracingService = context.GetExtension<ITracingService>();
IWorkflowContext workflowContext = context.GetExtension<IWorkflowContext>();
IOrganizationServiceFactory serviceFactory = context.GetExtension<IOrganizationServiceFactory>();
IOrganizationService service = serviceFactory.CreateOrganizationService(workflowContext.UserId);
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", "us");
try
{
using (var webClient = new WebClient())
{
webClient.Headers.Add("Accept", "application/json");
webClient.Headers.Add("Authorization", "apikey " + "ab15c4d1952ca886a92e5a");
Console.WriteLine(webClient.UploadString(uri, "POST", sampleList));
}
}
catch (WebException we)
{
using (var sr = new StreamReader(we.Response.GetResponseStream()))
{
Console.WriteLine(sr.ReadToEnd());
}
}
}
}
}
I register it as you showed me the link. I bind this custom workflow with the help of add step in crm's work flow. I call this work flow on button through js. My js code is below. My code is not working as it is worked in web client.
function getWorkflowId ()
{
debugger;
var entityId = ""; //Guid of record that workflow is to run on.
var workflowId = "29D2C96A-72C5-4A6D-85FE-9ADE9921F26C"; //Workflow Guid.
/*Generate Soap Body.*/
var soapBody = "<soap:Body>" +
" <Execute xmlns='schemas.microsoft.com/.../WebServices&;>" +
" <Request xsi:type=\'ExecuteWorkflowRequest\'>" +
//" <EntityId>" + entityId + "</EntityId>" +
" <WorkflowId>" + workflowId + "</WorkflowId>" +
" </Request>" +
" </Execute>" +
"</soap:Body>";
/*Wrap the Soap Body in a soap:Envelope.*/
var soapXml = "<soap:Envelope " +
" xmlns:soap='schemas.xmlsoap.org/.../&; " +
" xmlns:xsi='www.w3.org/.../XMLSchema-instance&; " +
" xmlns:xsd='www.w3.org/.../XMLSchema&;>" +
GenerateAuthenticationHeader() +
soapBody +
"</soap:Envelope>";
/* Create the XMLHTTP object for the execute method.*/
var serverUrl = Xrm.Page.context.getServerUrl() + "/MSCRMservices/2007/crmservice.asmx";
var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
xmlhttp.open("POST", serverUrl, false);
xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlhttp.setRequestHeader("SOAPAction", "schemas.microsoft.com/.../Execute");
/* Send the XMLHTTP object. */
xmlhttp.send(soapXml);
}
Please help to resolve my issue.
Thank You
Hi Andrii Butenko
Sorry for disturbing you one again. I have this code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using Microsoft.Xrm.Sdk;
using Microsoft.Xrm.Sdk.Workflow;
using System.Net;
using System.IO;
using Newtonsoft.Json;
namespace IntegrateMailChimpWithCRMTest
{
public class MailChimpTest : CodeActivity
{
protected override void Execute(CodeActivityContext context)
{
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", "u");
try
{
using (var webClient = new WebClient())
{
webClient.Headers.Add("Accept", "application/json");
webClient.Headers.Add("Authorization", "apikey " + "ab15c4d12aff98b952ca886a92e5a");
Console.WriteLine(webClient.UploadString(uri, "POST", sampleList));
}
}
catch (WebException we)
{
using (var sr = new StreamReader(we.Response.GetResponseStream()))
{
Console.WriteLine(sr.ReadToEnd());
}
}
}
}
}
What message I use to register this new step. I know this msdn.microsoft.com/.../gg328576(v=crm.5).aspx but I am confusing What message I use.? May you please help me.
Thank you
Just FYI. Plugin registration tool can be used to register both plugins and custom workflow activities.
If you anyway want to register custom workflow activities using PowerShell - unfortunately I'm not experienced in it so good luck doing it.
Hi Andrii Butenko
I need to register workflow not plug in. Am I write this msdn.microsoft.com/.../gg328153(v=crm.5).aspx link tells me that.?
Thank you
Is there any reason you use powershell to register Custom Worklfow Activity? Try Plugin Registration Tool from SDK.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156