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

Function does not fire

Jul 6, 2011 at 11:44 AM

Could someone please tell me why this alert returns 'undefined'. the path to my list is correct and the name of the workflow is the same as what is shown in the Name field of the Workflow Information page in SPD. The alert in the function to show the responseXML never fires.

alert ("Workflow template ID: "+ getWorkflowTemplateId(""));

function getWorkflowTemplateId(itemURL){
//get GUID for Workflow, eliminates need to change code everytime the workflow changes
   operation: "GetTemplatesForItem",
   item: itemURL,
   async: false,
   completefunc: function (xData, Status) {
     $(xData.responseXML).find("WorkflowTemplates > WorkflowTemplate").each(function(i,e) {
       // hard coded workflow name
       if ( $(this).attr("Name") == "Notify Delegate" ) {             
         var guid = $(this).find("WorkflowTemplateIdSet").attr("TemplateId");       
         if ( guid != null ) {
           workflowGUID = "{" + guid + "}";
           alert ("workflow guid" + workflowGUID);



Jul 6, 2011 at 12:28 PM
Edited Jul 6, 2011 at 3:03 PM


I don't see anything obvious. I'd add some alerts inside the getWorkflowTemplate function before and after the call to GetTemplatesForItem and make sure that the function is being called and receiving the proper parameter. You can also debug in Firebug or the Developer Tools in IE.


Jul 6, 2011 at 2:50 PM

Marc, i'm using the IE 8 Dev Toolbar, when I put a breakpoint on the $().SPServices line, and add some watches, I get the following:

completefunc 'completefunc' is undefined Error

  itemURL "" String

  xData.responseXML.xml 'xData' is undefined Error

  GetTemplatesForItem 'GetTemplatesForItem' is undefined Error

I'm using jQuery 1.5.2 and SPServices 0.6.1.

Any idea what would be causing these types of errors? I thought i was doing something simple, but have messed something up somehow. All of the other calls to SPServices on this page are working fine.


Jul 7, 2011 at 5:46 AM


I'm really not sure what's going on. The undefined errors that you are getting don't make much sense unless you're missing a closing quote or a comma or something.


Dec 15, 2011 at 4:29 PM

I was experiencing a problem getting this function to work (not exactly the same symptoms though) until I added a record identifier to the itemURL. For example "" would not work, but worked fine where the "16" was an existing record ID in the list and the "_.000" suffix was something I found in another discussion forum.  When I open my list in SharePoint Designer I see what appear to be files in my list file for every record in the list and each named with the record ID followed  by this "_.000", so I see a correlation but am completely unfamiliar with this taxonomy or structure of this data.

It seemed like this function should work with just a list description (e.g. return all the workflows for a given list) until I remembered that lists can contain different content types and, I think content types can have different workflows from other content types in the same list (does that sound right?).

I'm looking through the documentation to try and discover a better description of the "itemURL" parameter requirement, which might have saved me some time.

Thanks very much for creating this library and making it available!