Check out a document from a workflow in SharePoint 2010
Learn how you can use a SharePoint Designer 2010 site workflow to check out a document that is located in a document library on a SharePoint Document Center site.
Suppose you have a SharePoint Document Center site of which the Document ID Service has been enabled on the site collection to which the Document Center site belongs.
This means that each document on the site can be uniquely identified by a Document ID, no matter where the document is located.
Suppose now that you want to create a SharePoint Designer 2010 workflow to be able to check out a document that has a particular Document ID.
You can create a Site Workflow with an initiation parameter and that uses a Check Out Item SharePoint Designer List Action to be able to enter a Document ID and then run the workflow to check out the document that corresponds to that Document ID under the name of the user who ran the workflow.
To create a Site Workflow that can check out a document using a Document ID:
- In SharePoint Designer 2010, open the Document Center site.
- Click Workflows in the left navigation bar.
- Click Workflow > New > Site Workflow on the ribbon.
- On the Create Site Workflow dialog box, enter a name for the workflow and click OK.
- Click Workflow > Variables > Initiation Form Parameters on the ribbon.
- On the Association and Initiation Form Parameters dialog box, click Add.
- On the Add Field dialog box, type DocumentID for the field name, leave Single line of text selected as the information type, and click Next.
- On the Add Field dialog box, leave the Default value field empty, and click Finish.
- On the Association and Initiation Form Parameters dialog box, click OK.
- Click Workflow > Insert > Action > Check Out Item on the ribbon.
- Click the text this field on the workflow action.
- On the Choose List Item dialog box, select the name of the SharePoint library containing the document you want to check out (this SharePoint library would typically be called Documents on a Document Center site).
- On the Choose List Item dialog box, select Document ID Value from the Field drop-down list box, and then click the formula button behind the Value field.
- On the Lookup for Single line of text dialog box, select Workflow Variables and Parameters from the Data source drop-down list box, select Parameter: DocumentID from the Field from source drop-down list box, leave As String selected in the Return field as drop-down list box, and click OK.
- On the Choose List Item dialog box, click OK. Click Yes if SharePoint Designer prompts you with a warning.
- Click Workflow > Save > Publish on the ribbon to publish the workflow to the SharePoint site.
- Test the workflow.
To test the workflow:
- Go to the Document Center site, and then click Site Actions > View All Site Content.
- On the All Site Content page, click Site Workflows.
- On the Workflows page under Start a New Workflow, click the name of the workflow.
- On the Start workflow page, type in the Document ID of the document you want to check out and click Start.
The workflow should run and redirect you back to the Workflows page when it is done running. The text Completed should be listed in the Status column of the My Completed Workflows list.
Go to the SharePoint document library where the document is located and verify that it has indeed been checked out. Note that if the document was already checked out before running the workflow, the workflow should return the status of Canceled instead of Completed.
To be able to check out any document in SharePoint 2010 using a workflow, you must first have an action that can trigger the workflow (here the manual starting and entering of a Document ID was used to trigger the workflow), and then use the Check Out Item action in SharePoint Designer to check out the document.
Note that whichever document you try to check out using a SharePoint workflow, you must have a way of identifying the document, so that it can be selected through the workflow, and then checked out. The example above used a Document ID to select a document, because a Document ID is guaranteed to be unique.
- Steps to create a SharePoint Document Center
- How to add a version column to a SharePoint document library
- Document Center site template available in WSS 3.0?