sample code for documentation - WorkFlow

Nov 3, 2010 at 8:35 PM

Hi Marc,

I wrote a bit of code to find the TemplateId of a Workflow using the "GetTemplatesForItem" in the Workflow.asmx.  If you feel it would be helpful for others it could be added to the doco.

			var workflowGUID = null;
			$().SPServices({
				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") == "Workflow Name" ) {							
							var guid = $(this).find("WorkflowTemplateIdSet").attr("TemplateId");
							
							if ( guid != null ) {
								workflowGUID = "{" + guid + "}";
							}
						}
					});
				}
			});

Thanks!

Nathan

Coordinator
Nov 3, 2010 at 8:54 PM

Thanks, Nathan! I'll add it to the docs. Thanks for kicking back in.

M.