problem in calling workflow with javascript. plz help me.
-
vrijdag 27 april 2012 9:47
this is my code. for test put it , on save event form of entity wit name'itemsclaim'.
the name of entity that my workfolw , is made base on that is 'claim'
i should say , i have not built any websevice for this cod at all.
var workflowId ="5DF76028-DC06-4BD4-8506-404F8B734DB5";
var entityId = crmForm.ObjectId; // id if 'itemes claim' entity
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);
Alle reacties
-
vrijdag 27 april 2012 9:54Moderator
code looks gud,Are you getting any error ??
Mahain : Check My Blog
Follow me on Twitter
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question. -
vrijdag 27 april 2012 10:01no there isnt any error
-
vrijdag 27 april 2012 10:07ModeratorMake sure asyn is running, because asyn service is responsible for running workflow.
Mahain : Check My Blog
Follow me on Twitter
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question. -
vrijdag 27 april 2012 10:12how can i check that, my workflow automaticly work right, but here dosent work
-
vrijdag 27 april 2012 10:17
i should say, my work flow is mad base on 'claim' entity , and i wanna execute that when i am in 'itemsclaim' entity, isnt no problem for this structure,
in entity id varible , i should set which entity id?
-
vrijdag 27 april 2012 10:33Moderator
you should pass entity id on which workflow is created, so you need to pass claim entity id, you need to get claim record id first and then pass it from here.
Mahain : Check My Blog
Follow me on Twitter
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question. -
vrijdag 27 april 2012 11:24Moderator
Hello,
In case some error appeared it would be returned in the response. So to recheck that workflow was triggered you can use following approach:
alert(ExecuteWorkflow(crmForm.ObjectId, theWorkflowId));
Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)
- Als antwoord voorgesteld door Andrii ButenkoMVP, Moderator vrijdag 27 april 2012 11:24
-
zaterdag 28 april 2012 7:37thank you. Mahender Pal
-
zaterdag 28 april 2012 8:20Moderator
you are welcome !! , I will appriciate if you will close this thread if you got your solution.Mahain : Check My Blog
Follow me on Twitter
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.- Als antwoord gemarkeerd door shabnam2012 zondag 29 april 2012 17:18