The M-Files Community will be updated on Tuesday, April 2, 2024 at 10:00 AM EST / 2:00 PM GMT and the update is expected to last for several hours. The site will be unavailable during this time.

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

Can't set property of checkout objVer

Hello everybody,

I am trying to update a property with the following code: 

      [... lookups is initialized ...]

        propertyValueNew.Value.SetValueToMultiSelectLookup(lookups);

        var lastObjVer  =  dashboard.Vault.ObjectOperations.GetLatestObjVer(objVer.ObjID,false,true);
        if(!dashboard.Vault.ObjectOperations.IsObjectCheckedOut(lastObjVer.ObjID,false)){
            dashboard.Vault.ObjectOperations.CheckOut(lastObjVer.ObjID);
        }
       dashboard.Vault.ObjectPropertyOperations.SetProperty(lastObjVer, propertyValueNew);  <= error on this line
        dashboard.Vault.ObjectOperations.CheckIn(lastObjVer.ObjID);
when I execute this code, I get : 
" CustomControlSite.cpp, 1051, L'objet est verrouillé dans M-Files, mais la version à laquelle vous tentez d'accéder n'est pas la version actuellement verrouillée. Ceci est peut-être dû à des données non réactualisées sur le client M-Files. Veuillez rafraîchir l'écran. (0x8004002D) "
That means I am trying to update a non checkout objet. How? I don't understand
Thanks
Parents Reply Children
  • No, the method is fine. My point was that the result in some cases will be the latest version checked in on the server - let's say it is version 5. When you check out the object in order to manipulate it, version 6 is created. If you still attempt to change version 5, you will get an error. With LastObjVer you have an option AllowCheckedOut which in your case has been set to False. Changing it to True may solve the problem. I have sometimes had to save the latest version in a variable and then add 1 before I could use the result for my purpose.

  • the right code was 

            propertyValueNew.Value.SetValueToMultiSelectLookup(lookups);

            var lastObjVer  =  dashboard.Vault.ObjectOperations.GetLatestObjVer(objVer.ObjID,true,true);
            if(!dashboard.Vault.ObjectOperations.IsObjectCheckedOut(lastObjVer.ObjID,true)){
                lastObjVer = dashboard.Vault.ObjectOperations.CheckOut(lastObjVer.ObjID).ObjVer;
                //lastObjVer  =  dashboard.Vault.ObjectOperations.GetLatestObjVer(objVer.ObjID,true,true);
            }
            dashboard.Vault.ObjectPropertyOperations.SetProperty(lastObjVer, propertyValueNew);
            dashboard.Vault.ObjectOperations.CheckIn(lastObjVer);
    Thank you