This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Event Handler BeforeCheckOut problem

Hello all, here is my issue.
I've wrote a script in event handler beforecheckout in order to check-out objects linked with my main object when i check-out this main object.

Said otherwise:
There is a property multiselectlookup inside Object A with 2 objects linked : Object 1 and Object 2
I want to automatically check-out Object 1 and Object 2 when I check-out Object A

Here is my code:


Option Explicit

Dim Typeobjet
Dim Classeobjet
Classeobjet = Vault.ObjectPropertyOperations.GetProperty(ObjVer, 100).TypedValue.getlookupid 'PropertyValues.SearchForProperty(100).TypedValue.GetLookupID
Typeobjet = ObjVer.Type
if Typeobjet = 0 and Classeobjet = 27 then
Dim oObjID, oObjVer, oLookups, oLookup , oObjIDs
Dim oObjIDfils, IDfils, Verfils, oObjVerfils
Set oObjIDs = createobject("MFilesAPI.ObjIDs")
Set oLookups = Vault.ObjectPropertyOperations.GetProperty(ObjVer, 1287).TypedValue.GetValueAsLookups()
For Each oLookup In oLookups
    IDfils = oLookup.Item
    Verfils = oLookup.Version
    Set oObjIDfils = Vault.ValueListItemOperations.GetValueListItemByID(0, IDfils).ObjID
    Set oObjVerfils = Vault.ObjectOperations.GetLatestObjVer(oObjIDfils, True, True)
    If Vault.ObjectOperations.IsObjectCheckedOutToThisUserOnThisComputer(oObjIDfils, True) = True Then
        'Nothing
    Else
oObjIDs.add -1, oObjIDfils
    End If
Next
Call Vault.ObjectOperations.CheckOutMultipleObjects(oObjIDs)
end if


I've got an error saying to me that check-in and check-out operations must be paired in scripts....
Is anyone could help me.

Thanks in advance
  • It is a current limitation that any server-side script (e.g. an event handler) cannot leave another object in a checked out state. Simply: your code cannot check out another object and leave it checked out; it must also check it back in again before the code finishes.

    My assumption is that this limitation is to stop objects becoming checked out "to the server" and no-one else can process them.

    To my knowledge there is no way around this in server-side code.

    You could possibly implement something like this in UIX code (client-side) instead.

    Regards,

    Craig.