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!

  • I haven't seen this before (it's not an event that I tend to use much), but I assume it triggers because the file content is being changed (so there is a new file being "uploaded", it's just the same content as an older version).

    In this case might you just want to ignore the error (on error resume next / on error goto 0 around the SetProperties call)?  If it's rolling back then the "Document Date" property will be pulled from the previous version as well, which sounds like the correct behaviour...?

    Regards,

    Craig.

  • Thank you for answer!

    I will discuss to colleagues about possibility of ignoring this error. But actually I would like to understand why this error happens? I mean why I can not set another property in process of roll back? As I understand technically we are not going back in history, instead we are creating the new version and copying previous version there, so what is the problem to change one of property during this?

    Thank you!

  • I haven't investigated this specific situation (as I said: I don't use this event much), but this error is effectively due to a deadlock; the system won't allow a new script to be kicked off until the already-running script has finished.

    The one thing I am stuck on is why the system has allowed this script to run but won't allow the SetProperties call to run.  I wonder whether this is something to do with it being an "After" event.  Is there some other script that would be called when the object is updated?