StartWorkflow

Jan 4, 2010 at 4:43 PM

This relates to the CheckOutFile operation question that I posted earlier. I am needing to run a workflow when a document is checked out, but can't because WSS doesn't allow the workflow to run while a document is checked out, so I am using the StartWorkflow operation to run the workflow before the document is checked out.

Can you shed some light on how to use this operation? I am trying to run GetTemplatesForItem to get a GUID then run StartWorkflow but I am not getting anywhere.

Do you have any examples on how to use these operations?

Thanks.

Coordinator
Jan 4, 2010 at 6:09 PM

Assuming that you know the template GUID, you don't need to call GetTemplatesForItem.  I don't have any examples, but if you want to post what you have so far, we can try to work it through together.

M.

Jan 4, 2010 at 6:59 PM

Here is what I have so far. The templateID contains null when I display it. If I knew where to get the GUID I would be fine with skipping the call to GetTemplatesForItem.

function CheckOutBook(bookURL)
{
	var tempID = "";	

	tempID = $().SPServices({		
		operation: "GetTemplatesForItem",
		item: bookURL
                });

                alert(tempID);

                $().SPServices({
                    operation: "StartWorkflow",
                    item: bookURL,
                    templateId: tempID
	});

                $().SPServices({
		operation: "CheckOutFile",
		pageUrl: bookURL,
		checkoutToLocal: "false"
	});

                location.reload(true);
}
Coordinator
Jan 5, 2010 at 1:49 PM

Sorry, but I haven't had time to crack open a VM to take a look at this yet.  You should be able to get the Workflow TemplateId by going into the settings for the workflow in the UI and looking on the URL.

M.

Jan 5, 2010 at 5:37 PM

I haven't looked at it again, yet, either. I was able to get the templateID. I will work on it some more this afternoon and let you know if I come up with anything.

Jan 5, 2010 at 7:56 PM

Here's what I have found so far. This code:

var tempID = "{84fa0f84-1f80-49e9-9117-7fab3e7cb35a}";
$().SPServices({
       operation: "StartWorkflow",
       item: bookURL,
       templateId: tempID,
       workflowParameters: ""
});

Generates this SOAPEnvelope:

<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>
    <soap:Body>
         <StartWorkflow xmlns='http://schemas.microsoft.com/sharepoint/soap/workflow/' >
               <item>http://muskit9238/Training Book Library/The Power of Innovation Thinking.jpg</item>
               <templateId>{84fa0f84-1f80-49e9-9117-7fab3e7cb35a}</templateId>
               <workflowParameters></workflowParameters>
         </StartWorkflow>
     </soap:Body>
</soap:Envelope>
But I am getting an Error in response to this.
  ErrorText    The file '/_vti_bin/Workflow.asmx' does not exist.
Jan 5, 2010 at 7:59 PM
Edited Jan 5, 2010 at 8:07 PM

In that last post the ErrorText is supposed to read: ErrorText The file '/_vti_bin/Workflow.asmx' does not exist.  

Coordinator
Jan 5, 2010 at 8:04 PM

Aha.  I just looked back at your initial post and saw that you said "WSS".  The Workflow Web Services isn't available in WSS, only in MOSS.  If you look at this chart in the docs, I've tried to show which Web Services are available between the two.  Sorry that I didn't catch that right off.

M.

Jan 5, 2010 at 8:11 PM

Oh no, I see that now that you pointed it out. Well, I guess it's back to the drawing board on this one. Thanks.

Coordinator
Jan 5, 2010 at 8:13 PM

Sorry about that, but not my doing!  If you want to outline the business requirements, maybe I'll have some ideas for you.

M.