Posted by : Alon Havivi Friday, March 06, 2015
SharePoint 2013 workflows has out of the box workflow actions Check In and Check Out
To solve this, we can use the "call http web service" action with SharePoint REST API.
Follow these steps to check in a File as major version (publish):
1. Create a Workflow 2013 in SharePoint Designer
2. Rename the Stage to "Published"
3. Add a Build Dictionary action and name the output variable "JSonRequestHeader". Add a string variable named content-type with the value application/json;odata=verbose and add a new string variable named Accept with the value application/json;odata=verbose and click OK
4. Add a new Build Dictionary action and name the output variable "JSonRequestParameters"
Add a string variable named comment with the value Published by workflow
5. Check Out the file
6. Add Call http web service action with these properties:
[%Workflow Context:Current Site URL%]/_api/web/getfilebyserverrelativeurl('[%Current Item:Server Relative URL%]')/CheckIn(comment='Published by workflow',checkintype=1)
RequestHeaders: Variable: JSonRequestHeader
RequestContent: Variable: JSonRequestParameters
ResponseContent: Variable: JSonResult (Create new)
ResponseHeaders: Variable: JSonResponseHeaders (Create new)
ResponseStatusCode: Variable: responseCode
7. Then publish your workflow
The final result: