vikramjain23 - Thursday, December 16, 2010 6:07 AM:
Hello All,
I am able to create a document item using following code
------------------------------------------------------------
Dim Document As IOM.Item
Set Document = myInnovator.newItem("Document", "add")
Document.setProperty "name", "somename"
Dim rc As IOM.Item
Set rc = Document.Apply()
If rc.IsError Then MsgBox rc.getErrorString, , "Failed to create Document"
------------------------------------------------------------
The problem is : Document.Apply() creates and then unlocks the item.
But I wish to retain the lock on the document's first generation. Any clues ?
Best Regards,
Vikram Jain
Ronan - Thursday, December 16, 2010 9:13 AM:
The following methods should help to relock after Apply(): fetchLockStatus, getLockStatus, lockItem, unlockItem. See the API Reference Guide.
Note it doesn't answer your exact question ("to retain the lock on the document's first generation"); which as far as I know cannot be done. If you need to do stuff on the documents first generation, then do it before Apply(). Else it will logically be on a subsequent generation.
SamsAn - Friday, December 17, 2010 4:01 PM:
Hello.
Actually, standard Innovator Client setups locked_by_id property to have an item locked during Add operation. So, an option is to use the code like below.
Document.SetProperty("locked_by_id", myInnovator.getUserID())
This way gives better performance and the desired result in some special cases (for example, if the user has Can Add permission but does not have Edit permission for the Document then you will not be able to have the document locked via lock method).
SamsAn.
souheil - Thursday, December 16, 2010 6:37 PM:
the documentation states that item.Apply("lock") should work. The code below lock the items first generation as mentioned before.
Function CreateDocumentWithLock(doc)
if ( len(doc) = 0 ) then
MsgBox ("Empty Document Name")
WScript.Quit(0)
end if
Dim queryItem, resultItem
set queryItem = inn.newItem()
queryItem.setType("Document")
queryItem.setAttribute "id", inn.getNewID()
queryItem.setProperty "item_number",doc
queryItem.setProperty "name",doc
queryItem.setAction("add")
set resultItem = queryItem.apply()
if (resultItem.IsError() = True ) then
MsgBox resultItem.getErrorString, , "Failed to create Document"
else
queryItem.lockItem()
end if
End Function