OnAfterFileUpload triggers on roll-back operations?

Hello!

We met to an unexpectable problem in process of real using of M-Files. I created a simple event handler earlier that uses OnAfterFileUpload trigger and sets the property of Document to current date. It looks like this:

 
 

Dim pFileChangedOn: pFileChangedOn = vault.PropertyDefOperations.GetPropertyDefIDByAlias("PD.FileChangedOn")

Const tDocument = 0

If (ObjVer.Type = tDocument) Then

	Dim oPropertyValues: Set oPropertyValues = CreateObject("MFilesAPI.PropertyValues")
	Dim oPropertyValue: Set oPropertyValue = CreateObject("MFilesAPI.PropertyValue")

	oPropertyValue.PropertyDef = pFileChangedOn
	oPropertyValue.TypedValue.SetValue MFDatatypeDate, Now
	oPropertyValues.Add -1, oPropertyValue

	vault.ObjectPropertyOperations.SetProperties ObjVer, oPropertyValues

End If

It correctly working on for example file editing. And we had no problems until we tried to roll back the document to one of previous versions. We received an error "Operation not allowed. Script is being executed for the object "36311"":

ShellFrameWnd.cpp, 5675, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
CommandStore.cpp, 320, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
CommandStore.cpp, 403, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
MFShellCommands.cpp, 16462, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
MCommands.cpp, 317, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
MFShellCommands.cpp, 850, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
MFShellCommands.cpp, 3269, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
VaultDocumentOperations.cpp, 1502, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
ThreadOutCaller.cpp, 67, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
ThreadOutCaller.cpp, 583, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
VaultMethodCallTasks.cpp, 1282, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
CoVaultMountingDocumentOperations.cpp, 3051, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
CoVaultMountingDocumentOperations.cpp, 7146, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
CoVaultMountingDocumentOperations.cpp, 7302, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
CoVaultMountingDocumentOperations.cpp, 7608, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
DocumentCache.cpp, 7456, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
DocumentCache.cpp, 7517, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
RPCMethodCallWithRetry.h, 25, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
RPCMethodCallWithRetry.h, 25, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
RPCDocumentOperations.cpp, 12928, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
RPCDocumentOperations.cpp, 7700, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
MCallInLoop.h, 712, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
RPCDocumentOperationsHelper.cpp, 5220, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
RPCDocumentOperationsHelper.cpp, 12769, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
RPCDocumentOperationsHelperPrivate.cpp, 1290, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
RPCDocumentOperationsHelperPrivate.cpp, 4693, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
RPCDocumentOperationsHelper.cpp, 30009, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
RPCDocumentOperationsHelper.cpp, 23023, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
VaultDBSessionEvents.cpp, 578, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
VaultDBSessionEvents.cpp, 1602, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
VaultScriptSessionTemplates.cpp, 269, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
VaultScriptSessionTemplates.cpp, 328, Script execution failed. ((AfterFileUpload::PEP-30 Update File changed fields: 36311-20)) (0x800408BB)
VaultScriptSessionTemplates.cpp, 328, Operation not allowed. Script is being executed for the object "36311". (0x80040834)
VaultScriptSessionTemplates.cpp, 510, Operation not allowed. Script is being executed for the object "36311". (0x80040834)
CoActiveScriptSite.cpp, 894, Operation not allowed. Script is being executed for the object "36311". (0x80040834)
CoActiveScriptSite.cpp, 736, Operation not allowed. Script is being executed for the object "36311". (0x80040834)
AfterFileUpload::PEP-30 Update File changed fields, 17, Operation not allowed. Script is being executed for the object "36311". (0x80040834)
CoVaultObjectPropertyOperations.cpp, 381, Operation not allowed. Script is being executed for the object "36311". (0x80040834)
CoVaultObjectPropertyOperations.cpp, 406, Operation not allowed. Script is being executed for the object "36311". (0x80040834)
CoVaultObjectPropertyOperations.cpp, 475, Operation not allowed. Script is being executed for the object "36311". (0x80040834)
ServerVaultObjectPropertyOperationsHelper.cpp, 415, Operation not allowed. Script is being executed for the object "36311". (0x80040834)
RPCObjectOperationsHelper.cpp, 109, Operation not allowed. Script is being executed for the object "36311". (0x80040834)
CoRPCOverCOM.cpp, 6353, Operation not allowed. Script is being executed for the object "36311". (0x80040834)
RPCDocumentOperations.cpp, 7386, Operation not allowed. Script is being executed for the object "36311". (0x80040834)
MCallInLoop.h, 712, Operation not allowed. Script is being executed for the object "36311". (0x80040834)
RPCDocumentOperationsHelper.cpp, 4157, Operation not allowed. Script is being executed for the object "36311". (0x80040834)
RPCDocumentOperationsHelper.cpp, 3680, Operation not allowed. Script is being executed for the object "36311". (0x80040834)
RPCDocumentOperationsHelperPrivate.cpp, 11078, Operation not allowed. Script is being executed for the object "36311". (0x80040834)
RPCDocumentOperationsHelper.cpp, 11011, Operation not allowed. Script is being executed for the object "36311". (0x80040834)
RPCDocumentOperationsHelper.cpp, 12504, Operation not allowed. Script is being executed for the object "36311". (0x80040834)
VaultTrTrackerHelper.cpp, 425, Operation not allowed. Script is being executed for the object "36311". (0x80040834)
VaultTrTrackerHelper.cpp, 1109, Operation not allowed. Script is being executed for the object "36311". (0x80040834)
VaultTrTrackerHelper.cpp, 1314, Operation not allowed. Script is being executed for the object "36311". (0x80040834)
(M-Files 21.6.10322.8)

It points to line "vault.ObjectPropertyOperations.SetProperties ObjVer, oPropertyValues".

I did not find the reason and solution. Could you help me?

Thank you!