Solved

CRM 4.0; Need help with using Javascript to call a workflow.

Posted on 2010-08-20
4
986 Views
Last Modified: 2013-11-24
Hi All

I am trying to use Javascript to call a workflow. I have copied the code from a CRM blog;

/* the function */
ExecuteWorkflow = function(entityId, workflowId)
{
var xml = "" +
"<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
GenerateAuthenticationHeader() +
" <soap:Body>" +
" <Execute xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +
" <Request xsi:type=\"ExecuteWorkflowRequest\">" +
" <EntityId>" + entityId + "</EntityId>" +
" <WorkflowId>" + workflowId + "</WorkflowId>" +
" </Request>" +
" </Execute>" +
" </soap:Body>" +
"</soap:Envelope>" +
"";

var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Execute");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
xmlHttpRequest.send(xml);
var resultXml = xmlHttpRequest.responseXML;
return(resultXml.xml);
}

/* call */
var theWorkflowId = "<my workflow id>"; //change to your workflow Id
ExecuteWorkflow(crmForm.ObjectId, theWorkflowId);

I am the owner of the workflow and have the top level security role with full rights to everything.

The workflow is set to run 'On Demand', the scope is set to organisation.

I have tried testing this code in the onChange event of a text box and in the onClick function of a button on the form.

I have tried using the workflow id of other workflows I know are working.
....and still nothing.

Can anybody think of some step that I'm missing or some way of debugging the code to see what the problem is.

The only thing that I can see that is out of the ordinary is that the workflow has multiple entries in [dlrcc_MSCRM].[dbo].[workflowbase] whereas other workflows just have one. I have tried each workflowid listed against it.

Thanks.
0
Comment
Question by:abaines
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 29

Expert Comment

by:Feridun Kadir
ID: 33486590
Let's get some basics out of the way:

Is the workflow published, does it do the right things if you run it manually?
What error are you getting, if anything?

0
 

Author Comment

by:abaines
ID: 33498922
The workflow is published and I ran it manually against one case successfully.
No error msg at all. When I check the system jobs of the workflow after running the code, there is nothing there.

Thanks
0
 

Accepted Solution

by:
abaines earned 0 total points
ID: 34969169
Java solution used
0
 

Author Closing Comment

by:abaines
ID: 35005092
Question submitted by a colleague and problem was solved inhouse
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Salesforce.com is a cloud-based customer relationship management (CRM) system. In this article, you will learn how to add and map custom lead and contact fields to your Salesforce instance.
Desired Skill Set for Microsoft Dynamics CRM Technical Resources – Part II
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question