How can I tell if a SharePoint document is checked out?


My company uses K2 BlackPearl and SharePoint Portal Services 2010. I have a workflow that retrieves a sales order acknowledgement from SharePoint and sends it to the customer. The document is always in PDF format. Recently we have been experiencing a problem because K2 is sending an older version of the sales order acknowledgement to the customer. This happens when a user tries to open the acknowledgement pdf file to verify he/she uploaded the correct file. When Adobe X opens the pdf file the user is given two options "Check out and Open" or "Open". "Check out and Open" is on the left so they have a tendancy to click this button. They don't realize they are checking the document out when they do this so the document stays checked out and K2 retrieves the most recent checked-in version to send to the customer.

I've been playing around with the functions in the SharePoint Documents even in K2, mainly Check In Document and Undo Document Checkout. However, if a document is not checked out and you call the Undo Document Checkout the workflow errors out. Is there a way to determine if a SharePoint document is checked out before calling Undo Document Checkout?

Is there a better way to go about handling this? For example, is there a setting in SharePoint that I could change so that PDF files could not be checked out in this document library? Or, is there a way to "turn off" the "Check out and Open" button when the user is opening a PDF file?

Thanks in advance.

Holly Myers

0 Kudos
1 Reply

Re: How can I tell if a SharePoint document is checked out?

Hi Holly,

If you create a SmartObject of the Document Library (using K2 Settings) then you can access the properties of an individual document by calling the Load Method of the SmartObject. There is a property called "Checked Out To" which will be populated when the document is checked out to someone. You can use this in a Line Rule to check whether the document is checked out and then have this line go to an activity with an event that will undo the checkout.

Since the value might be null I used the Inline ConvertToString function on the Checked Out To field to convert it to string and I then compared it to the Empty String function to determine if it is blank. This seems to work.

If you do this check using the SmartObject you should be able to undo the checkout.