Quantcast
Channel: jQuery Library for SharePoint Web Services
Viewing all articles
Browse latest Browse all 6517

New Post: SPServices call not being recognized

$
0
0
I've got SPServices 2014.01 and JQuery 1.11.0 both loading in my masterpage. I've got a button on my list view that calls the function below. While troubleshooting, I added some alerts to see where it's breaking. The last alert at the end is saying that the workflow guid is null, so it's not finding the ID within the middle part (after the 'SPServices operation called' alert box).
function Rename(ItemURL, ItemID){
alert('Starting function');
var workflowDiv = 'WorkflowDiv' + ItemID
var workflowGUID = null;

//Find Workflow TemplateID for current document library
$().SPServices({
  operation: "GetTemplatesForItem",
  item: ItemURL,
  debug: true,
  async: false,
  completefunc: function (xData, Status) {
alert('SPServices operation called');
    $(xData.responseXML).find("WorkflowTemplates > WorkflowTemplate").each(function(i,e) {
      // hard coded workflow name
      if ( $(this).attr("Name") == "Rename" ) {              
        var guid = $(this).find("WorkflowTemplateIdSet").attr("TemplateId");        
        if ( guid != null ) {
          workflowGUID = "{" + guid + "}";
      }
        }
      });
  }
});

//Show loading image
document.getElementById('wfloader').style.visibility = 'visible';

//Call Workflow
$().SPServices({
  operation: "StartWorkflow",
  item: ItemURL,
  debug: true,
  templateId: workflowGUID,
  workflowParameters: "<root />",
  completefunc: function() {
    alert('Workflow GUID is ' + workflowGUID + '.');
    window.location.reload();
  }

});

}
The end result is that the function should find the workflow called "Rename" associated with the current item, then trigger it. This was all working prior to yesterday, but I did something that broke it and I'm pulling my hair out trying to find it. The workflow itself runs fine if I manually trigger it, and I've confirmed that the workflow name is just "Rename" with no extra spaces or anything.

Viewing all articles
Browse latest Browse all 6517

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>