0

There's been a lot of posting on here about this topic, and I can't seem to find a definitive answer here (or anywhere else online). In SP13, when viewing the source of a SP Workflow button, the code is rendered as javascript. Neither of the GUIDs presented seem to be the Workflow's Template ID.

I'm trying to make a URL to manually start a Workflow, and I keep getting routed to an error screen. I'm pretty certain that I don't have the proper WF Template ID. This is what I have so far:

="<a href=http://portal/_layouts/15/IniWrkflIP.aspx?List{F4E6RD31-1FD9-4559-N7AA-892B212FDB93}&ID={ID}&TemplateID={E92B2B59-DF72-48B1-9FFB-42F9789E6RDE}&?Source= http://Main/Lists/Contacts/AllItems.aspx"
1

yes, it requires some javascript code, but you can stuff it in a Calculated Column, so no need for Visual Studio or Designer

Can I add a start workflow link to a column in a list view?

Change the second-last line to your Workflow title,

Copy/Paste in a Calculated Column, set the datatype to Number

="<button style=""cursor:pointer;"" onclick=""{"
&"event.preventDefault();"
&"function startWorkflow(itemID, wfName) {"
&"  function __startWorkflow() {"
&"      var ctx = new SP.ClientContext.get_current(),"
&"          wfsManager = SP.WorkflowServices.WorkflowServicesManager.newObject(ctx,ctx.get_web()),"
&"          wfSubs = wfsManager.getWorkflowSubscriptionService().enumerateSubscriptionsByList(_spPageContextInfo.pageListId);"
&"      ctx.load(wfSubs);"
&"      ctx.executeQueryAsync(function () {"
&"          wfsEnum = wfSubs.getEnumerator();"
&"          while (wfsEnum.moveNext()) {"
&"              var wfSub = wfsEnum.get_current();"
&"              if (wfSub.get_name() === wfName) {"
&"                  wfsManager.getWorkflowInstanceService().startWorkflowOnListItem(wfSub,itemID,new Object());"
&"                  SP.UI.Notify.addNotification('Init Workflow: '+wfName+' on item: '+itemID, false);"
&"              }}});}"
&"  if (!SP.WorkflowServices) {"
&"      var script = document.createElement('script');"
&"      script.src = '/_layouts/15/sp.workflowservices.js';"
&"      script.onload = __startWorkflow;"
&"      document.head.appendChild(script);"
&"  } else {__startWorkflow();}"
&"}"
&"var TR=this;while(TR.tagName!='TR'){TR=TR.parentNode}"    
&"startWorkflow(TR.id.split(',')[1] , 'YOUR_WORKFLOW_TITLE_GOES_HERE');"
&"}"">Collect Signature</button>"
  • Thank you for the quick and thoughtful response! I am going to try this out and get back to you ASAP – TheJDScott Dec 14 '15 at 21:59
  • Wow. Incredible. This really helped me out so much. Just for kicks, do you know where I can edit/add a source URL in the script so the page refreshes on click, as well? – TheJDScott Dec 14 '15 at 22:09
  • Danny, this isn't working for me. It just stopped. I press the button, and the alert pops up on the top righthand corner, but then nothing happens after that. I copied and pasted the code, and put my Workflow Name 'sendEricAnEmail' in place of 'YOUR_WORKFLOW_TITLE_GOES_HERE'. the WF doesn't actually take place. Any idea what I could be doing wrong? – TheJDScott Dec 15 '15 at 0:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.