tag:blogger.com,1999:blog-6215355853745600041.post7652663373175898588..comments2023-06-29T06:30:57.142-07:00Comments on A Devotee of Dynamics CRM: Dynamics CRM - Trigger a workflow from JavaScriptAnkit Shahhttp://www.blogger.com/profile/02231940860065519189noreply@blogger.comBlogger24125tag:blogger.com,1999:blog-6215355853745600041.post-63634018818687657292019-08-26T23:28:02.736-07:002019-08-26T23:28:02.736-07:00Hi AJ,
Sorry for the delayed reply.
Can you let ...Hi AJ,<br /><br />Sorry for the delayed reply.<br /><br />Can you let me know where exactly are you facing the issue? Because the below code works for me for updating the Account by triggering the workflow from Contact. Make sure the workflow is set to trigger On Demand.<br /><br />function ContactEmailOnChange(executionContext) {<br /><br /> //Get the Account Id on Contact<br /> var formContext = executionContext.getFormContext();<br /> var accountAttribute = formContext.getAttribute("parentcustomerid");<br /><br /> if (accountAttribute != null && accountAttribute.getValue() != null) {<br /> var accountId = accountAttribute.getValue()[0].id;<br /><br /> var entity = {<br /> "EntityId": accountId // accountId<br /> };<br /><br /> var WorkflowId = "b7f7ebd1-3a91-43a2-8f41-35ed28ee4dfc";<br /><br /> var req = new XMLHttpRequest();<br /> req.open("POST", Xrm.Page.context.getClientUrl() + "/api/data/v9.0/workflows(" + WorkflowId + ")/Microsoft.Dynamics.CRM.ExecuteWorkflow", true);<br /> req.setRequestHeader("OData-MaxVersion", "4.0");<br /> req.setRequestHeader("OData-Version", "4.0");<br /> req.setRequestHeader("Accept", "application/json");<br /> req.setRequestHeader("Content-Type", "application/json; charset=utf-8");<br /> req.onreadystatechange = function () {<br /> if (this.readyState === 4) {<br /> req.onreadystatechange = null;<br /><br /> if (this.status === 200) {<br /> Xrm.Utility.alertDialog("Success");<br /> } else {<br /> Xrm.Utility.alertDialog(this.statusText);<br /> }<br /> }<br /> };<br /> req.send(JSON.stringify(entity));<br /> }<br />}Ankit Shahhttps://www.blogger.com/profile/02231940860065519189noreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-55920069779807435052019-08-19T08:48:09.854-07:002019-08-19T08:48:09.854-07:00Hi Ankit
Your code works for me well when I fire ...Hi Ankit<br /><br />Your code works for me well when I fire workflow on same entity. If I try this to fire a workflow on account entity from a contact entity it doesn't work. Can I know why please?<br /><br />Thanks<br />ArjArjhttps://www.blogger.com/profile/09819720633027998790noreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-41038366377419622422018-04-03T22:53:15.586-07:002018-04-03T22:53:15.586-07:00Hi sir
i am used same code in java script
occur so...Hi sir<br />i am used same code in java script<br />occur some problem "<br />Failed to load resource: the server responded with a status of 500 (Internal Server Error)"<br /><br /><br />Anonymoushttps://www.blogger.com/profile/12783904595163621501noreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-66606186023005982017-02-16T04:50:23.634-08:002017-02-16T04:50:23.634-08:00Hi,
You've specified that "The workflow ...Hi,<br /><br />You've specified that "The workflow id will change for record to record" <br /><br />Can you please elaborate more on that?Ankit Shahhttps://www.blogger.com/profile/02231940860065519189noreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-12398408884162937872017-02-14T23:17:37.374-08:002017-02-14T23:17:37.374-08:00Hi Work Flow id will change for record to record a...Hi Work Flow id will change for record to record and while debugging the script showing Guid Undefinedjithendrahttp://ankit.inkeysolutions.com/2013/03/dynamics-crm-2011-trigger-workflow-from.html?showComment=1443103461518#c7631408444406122143noreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-37041616115194306622016-01-03T23:41:46.993-08:002016-01-03T23:41:46.993-08:00Hi,
i have a requirement that i have to trigger a...Hi,<br /> i have a requirement that i have to trigger a workflow from ribbon button which is already there. i have used this same code.this is not working. and the button which supposed to do the action that also not happening . can you please guide me.<br />Thanks Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-73239389628148066522015-11-30T21:50:23.826-08:002015-11-30T21:50:23.826-08:00Hi,
It now supports all browsers, it is no more I...Hi,<br /><br />It now supports all browsers, it is no more IE-only since 24th Sep 2015.<br /><br />Thanks,<br />AnkitAnkit Shahhttps://www.blogger.com/profile/02231940860065519189noreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-21321464756058255082015-11-30T15:25:15.967-08:002015-11-30T15:25:15.967-08:00Is this JS code still IE-only, or will it now work...Is this JS code still IE-only, or will it now work with Chrome / Firefox, etc.?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-28503473282452626772015-11-23T10:39:56.669-08:002015-11-23T10:39:56.669-08:00Thank you so much man.. Worked like a charm for 20...Thank you so much man.. Worked like a charm for 2015. :)Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-10043009361535711422015-10-06T06:21:11.501-07:002015-10-06T06:21:11.501-07:00thanks Ankitthanks AnkitAnonymousnoreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-76314084444061221432015-09-24T07:04:21.518-07:002015-09-24T07:04:21.518-07:00Hello Rahul,
I have updated this post today and i...Hello Rahul,<br /><br />I have updated this post today and it should now work with CRM 2015.<br />Ankit Shahhttps://www.blogger.com/profile/02231940860065519189noreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-71904995377895850482015-06-20T00:43:10.739-07:002015-06-20T00:43:10.739-07:00not working crm2015not working crm2015Dynamics CRM - Best Tips & Trickshttps://www.blogger.com/profile/13310322662760066192noreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-74896744329724802662015-05-16T06:28:35.528-07:002015-05-16T06:28:35.528-07:00Hi,
Can you please validate each following point...Hi, <br /><br />Can you please validate each following point?<br /><br />1. Please validate the GUID value of workflow, is that correct?<br />2. Is the workflow activated?<br />3. Is it On Demand workflow?<br /><br />Thanks,<br />Ankit<br /><br /><br />Thanks,<br />AnkitAnkit Shahhttps://www.blogger.com/profile/02231940860065519189noreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-48385100949078431832015-05-11T05:38:30.474-07:002015-05-11T05:38:30.474-07:00Hi Ankit,
used the below code, however my workflow...Hi Ankit,<br />used the below code, however my workflow isnt firing can you please help?<br /><br />function startWorkflow() {<br /> var entityId = Xrm.Page.data.entity.getId(); <br /> var workflowProcessId = "54698A96-4926-4647-9A12-45DB4C2448B8"; //Workflow Guid.<br /><br /> var xml = "" +<br /><br /><br /> "" +<br /><br /><br /> "" +<br /><br /><br /> Xrm.Page.context.getAuthenticationHeader() +<br /><br /><br /> "" +<br /><br /><br /> "" +<br /><br /><br /> "" +<br /><br /><br /> "" + entityId + "" +<br /><br /><br /> "" + workflowProcessId + "" +<br /><br /><br /> "" +<br /><br /><br /> "" +<br /><br /><br /> "" +<br /><br /><br /> "";<br /><br /><br /> <br /><br /><br /> var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");<br /><br /><br /> xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);<br /><br /><br /> xmlHttpRequest.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Execute");<br /><br /><br /> xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");<br /><br /><br /> xmlHttpRequest.setRequestHeader("Content-Length", xml.length);<br /><br /><br /> xmlHttpRequest.send(xml);<br /><br /><br />} Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-44475017401738307882013-09-12T22:20:39.541-07:002013-09-12T22:20:39.541-07:00Hello James,
Yes, you just require to pass the va...Hello James,<br /><br />Yes, you just require to pass the values of these two parameters to startWorkflow Method. Ankit Shahhttps://www.blogger.com/profile/02231940860065519189noreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-17510887986163684072013-09-10T09:58:53.419-07:002013-09-10T09:58:53.419-07:00Hello, and thanks for your post. I'm attemptin...Hello, and thanks for your post. I'm attempting to integrate my workflow GUID and custom entity GUID and wanted to see what I might be doing wrong.<br /><br />Should I be adding the GUID like this? (I've removed code reference)<br /><br /> "EntityId" + "7bBF27441D-AF1F-4E7D-9F72-8C04B9EF5F55" + "/EntityId" + <br /> "WorkflowId" + "7b1D1F8595-A49F-432C-B1B0-C34ECF2EF55D" + "/WorkflowId" + <br /><br /><br />And is that the only place I would input them?<br /><br />thanks for your help.<br /><br />Jamesnoreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-3559702802336782912013-04-26T04:00:44.915-07:002013-04-26T04:00:44.915-07:00Hello Uday,
On your record window (either entity ...Hello Uday,<br /><br />On your record window (either entity or workflow) you can click on Copy a Link button. This will allow you to paste the URL of that record in notepad file or any other temporary location. From that URL you could identify the ID (Guid) of that record. I hope it is clear now. Ankit Shahhttps://www.blogger.com/profile/02231940860065519189noreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-69421067557887177212013-04-26T03:39:14.678-07:002013-04-26T03:39:14.678-07:00How and where can we find the entityid and workflo...How and where can we find the entityid and workflowid Uday Kumarhttps://www.blogger.com/profile/07435557070137774438noreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-56422316159158056652013-04-25T13:36:12.505-07:002013-04-25T13:36:12.505-07:00Hi ankit, how and where we can find that entityid,...Hi ankit, how and where we can find that entityid, workflowid.<br />Please adviceUday Kumarhttps://www.blogger.com/profile/07435557070137774438noreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-30661087932821890842013-03-25T01:47:31.684-07:002013-03-25T01:47:31.684-07:00Yes, that's true, at present the above functio...Yes, that's true, at present the above function did not support the other browsers.Ankit Shahhttps://www.blogger.com/profile/02231940860065519189noreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-1175850812677951722013-03-25T01:38:22.586-07:002013-03-25T01:38:22.586-07:00will not work on non IE Browsers. (Cross Browser f...will not work on non IE Browsers. (Cross Browser functionality in UR 12) because of the ActiveX call.Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-46218633737333870202013-03-20T04:29:16.346-07:002013-03-20T04:29:16.346-07:00No, at present it runs only at record level(via en...No, at present it runs only at record level(via entity form).Ankit Shahhttps://www.blogger.com/profile/02231940860065519189noreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-78695798423295596232013-03-19T11:33:45.498-07:002013-03-19T11:33:45.498-07:00is it possible from a home page of an entity ? if ...is it possible from a home page of an entity ? if i select 10 record in the same time ? does the workflow retrive the 10 GUID of the 10 records ?Anonymousnoreply@blogger.comtag:blogger.com,1999:blog-6215355853745600041.post-12918677537295489202013-03-17T13:37:44.397-07:002013-03-17T13:37:44.397-07:00ExcellentExcellentAnonymousnoreply@blogger.com