This project has moved. For the latest updates, please go here.

No workflows being returned with GetTemplatesforItem

Jul 2, 2015 at 10:23 PM
Edited Jul 2, 2015 at 10:55 PM
Anybody got any thoughts why i wouldn't be getting any workflows returned using the GetTemplatesForItem operation on a document library in SharePoint Online? It returns the site name and list name (so i am assuming the item URL is correct) but the workflows section is empty (<WorkflowTemplates></WorkflowTemplates>) despite being able to go into SharePoint and manually run them.

This is the code I am using:

(documentURL is in the format: https://sitename/sites/subsite/documentLibrary/filename.pdf)
function approvePolicy() {      
        operation: "GetTemplatesForItem",
        item: documentURL,
        async: false,
        completefunc: function (xData, Status) {
            $(xData.responseXML).find("WorkflowTemplates > WorkflowTemplate").each(function(i,e) {
                if ( $(this).attr("Name") == "Send Reminder Emails" ) {              
                    var guid = $(this).find("WorkflowTemplateIdSet").attr("TemplateId");  
                    console.log("Variable guid set to: " + guid);      
                    if ( guid != null ) {
                        workflowGUID = "{" + guid + "}";
                        console.log("Variable workflowGUID set to: " + workflowGUID);  
Jul 3, 2015 at 2:16 PM
Keep in mind that the SOAP services are old and haven't seen any love in a while now. If you check the docs for the operation, you'll see that "If you use the full URL to a list, only workflows explicitly associated with the list are returned" (See In other words, there are types of workflows that may not be returned from the call.

Jul 7, 2015 at 3:29 AM
Thanks for the quick response, Marc!

It turns out I had to convert the workflows from SP 2013 to SP 2010 workflows. Once recreated as SP2010 workflows, the script returned the workflow names. Luckily the workflow actions were all available in SP 2010 workflows.
Jul 7, 2015 at 1:10 PM
If you needed to use 2013 WFs, you can use this script to fire off the workflows in JavaScript:

Jul 8, 2015 at 11:45 PM
Awesome! Thanks Matthew. That will come in very handy.