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

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 :)