Solved

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

Posted on 2010-08-20
4
983 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 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Hello All, In previous article we used Hortonworks sandbox to work with Hadoop. Now, lets think to create own single node Hadoop on Linux. Here we Install and Configure Apache Hadoop on UI based Oracle Linux. I assume, you have VMware installe…
Read about achieving the basic levels of HRIS security in the workplace.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

775 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