Wait for document check-in

May 22, 2015 at 1:19 PM
Edited May 22, 2015 at 1:23 PM
Has anyone scripted with SPservices, a 'wait for document check-in' before proceeding to process a document. I have GetListItems, CheckOutFile, UpdateListItems, CheckInFile all working, but want to place the wait for check-in, probably inside my GetListItems function, before it proceeds to CheckOutFile, UpdateListItems, and then CheckInFile. Reason being, a worklfow could be working on an item, or user might have document checked-out, and I do not want to process document until it is available to do so. I am using SP2007/MOSS, with SPServices-2014.01.

One other aspect I am unsure of, is how to force new version be recorded against the document, when whole process completes, so that it is viewed correctly in the version history of the document. but nothing appears in the Versions.asmx, that I can see.
May 22, 2015 at 1:26 PM
You could re-poll for as long as the page is open, but what you're describing would really be an event receiver on the server or a workflow.

The versioning thing ought to work, I think.

May 22, 2015 at 1:36 PM
Thanks Marc, for your quick response!

I am initiating this script from a custom folder content type edit screen. When a user interacts with a folders checkbox, to archive. I pass this 'archive' aspect to a particular document inside that folder, to allowing for various custom views of those documents, that would now have that 'archive' data set on them. So not sure repolling on the page (EditForm.aspx of the custom folder content type) would be ideal. I was hoping their was somehting I could do with regards to when I retrieve the document through GetListItems, then perhaps check its SPCheckOutStatus, and then wait for SPCheckOutStatus to equal none, before proceeding with the rest of the function calls. This would all be moot obviously with SP2010+ being able to 'percolate' data down to child elements, out of the box! :-)
May 22, 2015 at 1:50 PM
When I was talking about the re-polling, I did mean in GetListItems. Basically in a setTimeout loop until your condition was met.

May 22, 2015 at 1:59 PM
Thanks Marc, I'll try that route. I appreciate your suggestions.
May 22, 2015 at 7:58 PM
HI Marc,

I ended up pulling back CheckedOutUser attribute and then testing whether CheckedOutUser==undefined, in order to proceed, with the else branch stating to come back at another time and try setting the checkbox then. Everything works great, except for one thing. As I have enforced check-out for editing on this document library, I had to utilize check-out method on the item before doing the updating the list item method and then check-in method the item. The changes are applied and the check-in/out allworks properly with no errors, however the change is recorded in the most recent version of the doucment and not as a separate new version, when the change is set through SPservices. Is there a way to set or increment the version before I check it back in? I had thought that SharePoint should handle this itself, but perhaps it is not being recorded as an event that would trigger a new version entry, versus just adding to the last version changes? I did pass the modifed date (converted as a javascript date object) when I did the checkout. Could that have something to do with no new version being applied?