This project has moved and is read-only. For the latest updates, please go here.

GetTemplatesForItem issue

Dec 8, 2011 at 6:08 PM
Edited Dec 8, 2011 at 9:57 PM

I'm working on a script that will live on a page with connected web parts.  The script is tied to a button click event to take a user to an initiation form for a workflow.  I'm using jquery 1.5.2 and SPServices 0.61 in this site collection.  Everything is working up until the SPServices call.  jQuery is on my master page and I know my reference to SPServices is good because it returns the query string variable I'm expecting to build the item url.  This is what the script looks like:

<script type="text/javascript">
function gotoWorkflow() {
var queryStringVals = ""
var goTo = ""
var workflowURL = ""
var item = ""
var template = ""
var thisPage = ""
var siteRoot = ""

 queryStringVals = $().SPServices.SPGetQueryString();
 goTo = queryStringVals.SelectedID.toString();
 siteRoot = $().SPServices.SPGetCurrentSite();
 thisPage = $(location).attr("href");
 item = siteRoot + "/Lists/Courses/" + goTo + "_.000";
    operation: "GetTemplatesForItem",
    item: item,
    async: false,
    completefunc: function (xData, Status) {
   alert(xData.responseXML.xml); //nothing is alerted /sadpanda
      $(xData.responseXML).find("WorkflowTemplates > WorkflowTemplate").each(function(i,e) {
       if ( $(this).attr("Name") == "Email Users" ) {             
         var guid = $(this).find("WorkflowTemplateIdSet").attr("TemplateId");       
          if ( guid != null )
            template = "{" + guid + "}";
 workflowURL = siteRoot + "/_layouts/NintexWorkflow/StartWorkflow.aspx?List=efe34953-9c0b-448d-8481-a55513321217&ID=" + goTo +"&TemplateID=" + template + "&Source=" + thisPage;
 window.location.href = workflowURL

<div id="buttonDiv">
 <input name="Button2" type="button" value="Email Users" id="emailButton" onclick="gotoWorkflow();">

Dec 8, 2011 at 6:30 PM


I'm not exactly sure, but I don't think that the URL you are using for the item looks right. My guess is the it wants a URL more like DispForm.aspx?ID=1, but I could be mistaken.


Dec 8, 2011 at 6:35 PM

From other references to this like starting workflows, examples show the number_.000 format.  I can try to build it as the dispform route and see if that helps resolve the issue. 

Dec 8, 2011 at 6:41 PM
Edited Dec 8, 2011 at 6:42 PM

I haven't done anything with the workflow operations in quite a while. See if either of these posts help.


Dec 8, 2011 at 6:47 PM

I'll look at those, the MSDN documentation says http://server/manpath/site/lists/list/ should be sufficient but that doesn't help either.  I've used this before so I know it works, I'm just not understanding why it isn't in this instance.

Dec 8, 2011 at 8:38 PM
Edited Dec 8, 2011 at 8:45 PM

I've referenced those in the past where I was directly triggering a workflow from a button click.  This one is just taking the user to the initiation screen as there is some information the workflow needs before it executes.  While the workflow won't likely be edited often, as it's a simple email workflow, I'd like to keep it dynamic so if I do have to make changes, I don't have to update the script to point to a new template ID. 

This affirms that for list items the url I'm building is accurate,

This is what my web service response looks like when just using the link to the list:

<?xml version="1.0" encoding="utf-8"?>
 <soap:Envelope xmlns:soap="" xmlns:xsi="" xmlns:xsd="">
  <GetTemplatesForItemResponse xmlns="">
     <Web Title="ECU Training" Url="" />
     <List Title="Courses" Url="" />


I get an empty string when I use the full item url in the_.000 fashion when I do a console.log.  Very frustrating.

Wondering if it has anything to do with the fact this is a Nintex workflow I'm trying to fetch and not a standard SPD designed one.

Dec 8, 2011 at 9:43 PM

Sorry for the confusion all, this is working as expected.  My issue was as I was testing this out, someone had deleted the list item I was testing against and therefore nothing was being returned from the web service call.  Talk about aggrevating.

Dec 8, 2011 at 9:45 PM

It's always something, isn't it?

No worries, and I'm glad you got it sorted out.


Mar 18, 2014 at 11:46 PM
Same problem.
When I try to get GetTemplatesForItem with "_.000" item Url I receive error Status
And when I try with "EncodedAbsUrl" - I get the response, but there are NO workflow templates associated with Item
What to do?
Any ideas appreciated!