Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2010-08-20
4
Medium Priority
?
990 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
  • 3
4 Comments
 
LVL 30

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

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

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
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

885 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