0
votes

Trying to implement document locking in a small database. We use it in XPiNC. I found Julian Boss's excellent answer in in which he provides a javascript function that seems to have everything I need.

So in a small test database I added the script library and added as a resource. In my edit button I have the following code:

var ntdDoc:NotesDocument = document1.getDocument();
documentLocking.lockDoc(ntdDoc)

But this throws the following error:

Script interpreter error, line=2, col=17: [TypeError] Error calling method 'lockDoc(lotus.domino.local.Document)' on an object of type 'Object [JavaScript Object]'
     1: var ntdDoc:NotesDocument = document1.getDocument();
->   2: documentLocking.lockDoc(ntdDoc)

I have tried passing in the data source and that didn't work either. What do I need to pass?

1
Are you sure that 'documentLocking' is available as a global object? - Per Henrik Lausten
I am not. How do I make it available as a global object? - Bryan Schmiedeler
Bryan, documentLocking should be a function in a SSJS script library (with that exact name) which you include in your XPage. Is that the case? - Per Henrik Lausten

1 Answers

1
votes

That answer is a few years old and I'm not sure of the current recommendations around storing SSJS global variables. Storing SSJS functions as objects is no longer recommended.

Domino has in-built document locking, which is equally valid for use in XPages. Mastering XPages Second Edition had a very good and comprehensive walk-through of how to use the document locking. The only (potential) gotcha is that you need to lock the document before deleting it - because to delete it you need to modify it, and to modify it you need to lock it.