Hi,
I have a problem with SetPropertiesOfMultipleObjects.
Summary of the code: Find objects, CheckOutMultipleObjects, GetObjectVersionAndPropertiesOfMultipleObjects, SetPropertiesOfMultipleObjects (try set one boolean value of every object), CheckInMultipleObjects
So here is the code:
[TaskProcessor(TestChangerQueID, TestChangerTaskName, TransactionMode = TransactionMode.Full, MaxRequeues = 0, MaxRetries = 0)] [ShowOnDashboard("Test Changer", ShowRunCommand = true)] public void TestChanger(ITaskProcessingJob<TaskDirective> job) { Vault vault = job.Vault; MFSearchBuilder mFSearchBuilder = new MFSearchBuilder(vault) .Class(Configuration.Structure.Classes.Target) .IsCheckedOut(false) .Deleted(false); ObjectVersions results = mFSearchBuilder.Find(maxResults: 499).ObjectVersions; ObjVers objVers = results.GetAsObjVers(); ObjIDs objIDs = objVers.GetAllDistinctObjIDs(); vault.ObjectOperations.CheckOutMultipleObjects(objIDs); var versAndProps = vault.ObjectOperations.GetObjectVersionAndPropertiesOfMultipleObjects(objVers, LatestVersions: true, AllowCheckedOut: true, AllowMissingObjectVersions: true); ObjVers freshObjVers = new ObjVers(); foreach (ObjectVersionAndProperties item in versAndProps) { freshObjVers.Add(-1, item.ObjVer); } MFPropertyValuesBuilder builder = new MFPropertyValuesBuilder(vault) .Add(Configuration.Structure.Properties.Target, MFDataType.MFDatatypeBoolean, Configuration.Settings.Value); SetPropertiesOfMultipleObjects(vault, freshObjVers, builder.Values); vault.ObjectOperations.CheckInMultipleObjects(freshObjVers); } private void SetPropertiesOfMultipleObjects(Vault vault, ObjVers objVers, PropertyValues propertyValues) { SetPropertiesParamsOfMultipleObjects propertiesOfMultipleObjects = new SetPropertiesParamsOfMultipleObjects(); foreach (ObjVer objVer in objVers) { SetPropertiesParams param = new SetPropertiesParams { ObjVer = objVer, PropertyValuesToSet = propertyValues, }; propertiesOfMultipleObjects.Add(-1, param); } vault.ObjectPropertyOperations.SetPropertiesOfMultipleObjects(propertiesOfMultipleObjects); }
The code always throws when the line
vault.ObjectPropertyOperations.SetPropertiesOfMultipleObjects(propertiesOfMultipleObjects);
is called.
The error says: "Extension method failed. VaultTransactionController.OnNewTransactionSystem.Runtime.InteropServices.COMException (0x80040001): Kohde on varattu muokattavaksi M-Filesissa, mutta käyttämäsi versio ei ole muokattavaksi varattu versio kohteesta. Useimmiten tämä johtuu vanhentuneesta tiedosta asiakasohjelmistossa."
Roughly translated: "The object is checked out in M-Files but used version isn't the checked out version of the object. Most often this is due to outdated information in the client software"
I have tried this without the ObjectOperations.GetObjectVersionAndPropertiesOfMultipleObjects but no success.
Any ideas what is wrong?