Wednesday, May 2, 2012

Use "Check Out" and "Check In" actions with globally reusable workflows in SharePoint Designer 2010


Supporters of End User


Item is currently unrated. Press SHIFT+ENTER to rate this item.
Categories:SharePoint Designer; Workflow; Site Manager/Power User; MOSS; WSS; 2007; 2010

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.
  3. 2011-12-07-UseCheckOut-01.png

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.
    1. Do not select a List. Leave the “this list” as is.
  3. Save your workflow.
  4. 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.
  5. 2011-12-07-UseCheckOut-02.png
  6. Right click on the .xoml file and click “Open With”, “SharePoint Designer (open as XML)”
  7. 2011-12-07-UseCheckOut-03.png
  8. Click Ctrl+F to find “CheckOutItemActivity”
  9. In that row you will see: ListItem={x:Null}” ListID=”{x:Null}”
  10. Replace “x:Null” in “ListItem=” with “ActivityBind ROOT, Path=__item”
    2011-12-07-UseCheckOut-06.png
  11. Replace “x:Null” in “ListId=” with ActivityBindROOT, Path=__list”
    2011-12-07-UseCheckOut-07.png
  12. Click “Ctrl+F” to find “CheckInItemActivity”
  13. Repeat steps 8 and 9 for this line item.
  14. 2011-12-07-UseCheckOut-04.png
  15. Save this file.
  16. Click on “Workflows” and click on the workflow name to open the workflow file as you normally would.
  17. Do not make any changes but click “Save”
  18. 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”.
  19. Close Designer and re-open it
  20. Click on “Workflows” and click on your workflow to open and edit it.
  21. Find the step where you checked out and checked in the item.
  22. The action should say “Check out item in Current Item” and “Check in item in Current Item with comment: xxx”
  23. 2011-12-07-UseCheckOut-05.png
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.

No comments:

Post a Comment