Hello guys,
For the context : I would like to know who was the last person who changed a certain property.
For this, I created an Event Handler (AfterSetProperties) where I get my current user and check if the property was changed based on its previous version
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
Option Explicit
' Get the required properties for this script
Const CLASS_PROPERTY = 100 'Class Property
CONST EMPLOYES = 1420
CONST USER_TEST = 1549
Const DOCUMENT_OBJECTTYPE = 0 ' Document Object Type
Dim PropertyValues : Set PropertyValues = Vault.ObjectPropertyOperations.GetProperties( ObjVer, True )
'If the object is a document and belongs to the "Document test" class
if( ObjVer.Type = DOCUMENT_OBJECTTYPE) and (PropertyValues.SearchForProperty(CLASS_PROPERTY).TypedValue.DisplayValue = "Document test") then
Dim employesDisplayValue : employesDisplayValue = PropertyValues.SearchForProperty(EMPLOYES).TypedValue.DisplayValue
if NOT(employesDisplayValue="" AND ObjVer.Version > 1) then
dim previousVersion : previousVersion = (ObjVer.Version - 1)
Dim newObjVer : set newObjVer = CreateObject("MFilesAPI.ObjVer")
newObjVer.SetIDs 0, ObjVer.ID, previousVersion
Dim previousProperties : set previousProperties = Vault.ObjectOperations.GetObjectVersionAndProperties(newObjVer).Properties
When i'm testing the script, I'm getting this error :
- AfterSetProperties::DocumentTestModifiedBy, 36, The script could not be executed because the maximum number of nested scripts was exceeded. (0x80040969)
I've already checked the execution order : https://www.m-files.com/user-guide/2018/eng/execution_order_of_scripts.html and i'm pretty sure that's the event handler i need to use.
Any help will be very appreciated
Thank you very much
Claudio - EVOK - Altern8 SA