Archive: Use “Check Out” and “Check In” actions with globally reusable workflows in SharePoint Designer 2010

This article was originally written in December 2011.  It is being reposted here as an archive.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

I love that SharePoint Designer gives you the ability to create reusable workflows.  It’s even better that you can select “All” as the content type.   However, I have come across a minor issue with being able to update an item that requires check in and check out via workflow and being able to apply that to “any” list, content type, page or document.  You can’t start a workflow on an item that’s checked out, but you can’t update an item that’s checked in.  When you try to use the “Check out” action, you are expected to select a list to check out an item from.

The Requirement:  Create a workflow that will make field updates to a document or page that requires check-in / check-out.  This workflow must be able to work on any page or document library in the site collection.

The Problem:

  1. I can’t update any old field on a checked-in item housed in a library where check-out is required.
  2. SharePoint Designer workflow action “Check out item” wants me to choose a List Item to check out, but I need to be able to use this on any list or content type.
SharePoint Designer 2010 - Check Item Out

SharePoint Designer 2010 – Check Item Out

The Solution: a modification to the .xoml file that tells the workflow to use “this item” regardless of the list.

Disclaimer:  If you want to model an out of the box workflow, always copy and modify…it is never a good idea to modify the out of the box global workflows directly.

Steps:

  1. Set up your workflow with placeholders for your check-in and check-out actions.
  2. Add “Check out item in this list” and “Check in item in this list with Comment” actions to the appropriate steps on your workflow.
  3. Do not select a List.  Leave the “this list” as is.
  4. Save your workflow.
  5. Go “All Files”, “Workflows”, click on the workflow name in the window below “All files” so that your workflow displays it’s files in the window on the right side of the screen.
SharePoint Designer 2010 - Find Workflow Files

SharePoint Designer 2010 – Find Workflow Files

  1. Right click on the .xoml file and click “Open With”, “SharePoint Designer (open as XML)”
SharePoint Designer 2010 Workflow - Open File as XML

SharePoint Designer 2010 Workflow – Open File as XML

  1. Click Ctrl+F to find “CheckOutItemActivity”
  2. In that row you will see:  ListItem={x:Null}” ListID=”{x:Null}”
  3. Replace “x:Null” in “ListItem=” with “ActivityBind ROOT, Path=__item”
  4. Replace “x:Null” in “ListId=” with ActivityBindROOT, Path=__list”
  5. Click “Ctrl+F” to find “CheckInItemActivity”
  6. Repeat steps 8 and 9 for this line item.
SharePoint Designer 2010 Workflow - Replace Check In/Check Out Code

SharePoint Designer 2010 Workflow – Replace Check In/Check Out Code

  1. Save this file.
  2. Click on “Workflows” and click on the workflow name to open the workflow file as you normally would.
  3. Do not make any changes but click “Save”
  4. When Designer pops up to say that a different version of the .xoml file was saved, and politely asks if you want to replace that file with this one click “No”.
  5. Close Designer and re-open it
  6. Click on “Workflows” and click on your workflow to open and edit it.
  7. Find the step where you checked out and checked in the item.
  8. The action should say “Check out item in Current Item” and “Check in item in Current Item with comment: xxx”
SharePoint Designer 2010 Workflow - Replace Check In Check Out Code Results

SharePoint Designer 2010 Workflow – Replace Check In Check Out Code Results

I’m not sure why you have to close Designer and re-open it before you can see your changes, maybe it’s just my wonky machine, but I have to follow these steps exactly on order for the change to “take”.

 

Notes:

  • Make sure that you do NOT have “end on change” feature turned on, or your workflow will stop immediately after making the change without checking the document  back in.

Leave a Reply

Your email address will not be published.