VBScript - Adding a Property while modifying class, WF and step

Hello everyone,

Unfortunately, I couldn't find the answer to my question concerning this subject and I've found a solution so wanted to share it with you.
When you're trying to convert a document into another class while also changing its workflow, you need to use Vault.ObjectPropertyOperations.SetAllProperties and setting AllowModifyingCheckedInObject to TRUE

Now, you could have a required property on the other class and you'd need to add to the current document. So this is how you could do it :

' Adding the mandatory date to the current document
dim datePropVal : Set datePropVal = CreateObject("MFilesAPI.PropertyValue")
datePropVal.PropertyDef = CONFIRMATION_DATE_PROP 
datePropVal.TypedValue.SetValue MFDatatypeDate, Date()
Vault.ObjectPropertyOperations.SetProperty ObjVer, datePropVal
'Add the created property value with the date into the current PropertyValues Object
PropertyValues.Add 0, datePropVal

'Change the class ID
PropertyValues.SearchForProperty(CLASS_ID).TypedValue.SetValue MFDataTypeLookup, CONFIRMATION_CLASS_ID
'Set All properties to Allow modifying checked in object
Vault.ObjectPropertyOperations.SetAllProperties ObjVer, true, PropertyValues

However, if you have any suggestions, tips for this particular case, do not hesitate :)