Checkout and Check-in Activity in SharePoint 2013 Workflows

Introduction

This article explains how to use Checkout and Check-in Activity in SharePoint 2013 Workflows using Visual Studio 2013.

Step-by-step Implementation

  1. Open the SharePoint site and click on the icon that is available in the right side of the site and click Site contents from the menu list or click Site Contents from the Quick Launch as shown below.

    Open SharePoint site

  2. Click the add an app icon to create a List or Document Library.

    Click add

  3. From the apps page click Document Library and provide the name as WFDocumentsCOCI in the TextBox and click Create.

    Click Document Library

  4. Open Visual Studio 2013 and create a new SharePoint 2013 Empty Project and provide the name and click OK.
  5. In the next screen provide the site collection name you want to deploy the solution and choose Deploy as Sandboxed solution option and click Finish.
  6. Right-click on the project and add New Item as Workflow and provide the name WFCheckoutCheckInItem to the workflow and click the Add button.
  7. In the next screen, provide the name of the workflow is WF Checkout CheckIn Item and choose the List Workflow option and click Next.
  8. In the next screen choose Document Library, history list and task list as follows and click Next

    history list and task list

  9. Select the option of User Manually to start the workflow and click Finish to add it
  10. Drag and drop the WriteToHistory activity and provide the message as “WF Started” and “WF Completed” respectively.
  11. Drag and drop the WriteToHistory activity between the two WriteToHistory activities and provide the message as "Document is going to check-out..."
  12. Drag and drop the CheckOutItem activity and set the properties as below.

    CheckOutItem

  13. Drag and drop the WriteToHistory activity and provide the message as "Item Checked-out successfully"
  14. Drag and drop the WriteToHistory activity and provide the input message as "Wait for 2 mins..."
  15. Drag and drop the DelayUntil activity and set Date properties as DateTime.UtcNow.AddMinutes(2)
  16. Drag and drop the WriteToHistory activity and provide the input message as "Item Going to Check-in..."
  17. Drag and drop CheckInItem activity and set the properties as shown below.

    CheckInItem

  18. Drag and drop the WriteToHistory activity and provide the input message as "Item Checked-in successfully"
  19. Build and deploy the project.
  20. Open the Document Library page and upload the new document and start the workflow to the library. Then see that the item has been checked out.

    start the workflow

  21. Let us see the Workflow History after the document has been checked out.

    Workflow History

  22. Then wait for 2 minutes and edit the document you want to change.

  23. Click on the Name of the document and it will open in a Word document and select the option of Edit Document and Edit the document as below or whatever you want.

    Edit Document

  24. Save it and close the document.
  25. Again open the document and see the changes in the saved document.

    saved document

  26. Refresh the page after 2 minutes and see that the item has been checked-in as below.

    Refresh the page

  27. See that the Workflow History list and the WF has been completed.

    Workflow History list

  28. See the changes in the timings.

Up Next
    Ebook Download
    View all
    Learn
    View all