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

Increment revison on file drag n drop

Hi all, related to my other query

When files are dragged into a Multi File Document, I want to increment the revision number property
(given certain conditions about workflow states and so on)

The problem is 
1) If I put this into BeforeCheckInChanges, it will trigger every time the document is changed by any process
(it needs to be only if a new file has been dragged in)

2) If I put this into BeforeFileUpload / AfterFileUpload, those event handlers have no awareness of ObjVer, only the FileVer.
(so then can't edit properties on the Document ObjVer)

Is this possible?
Many thanks

  • According to the M-Files Event Handler documentation the ObjVer variable is available for the AfterFileUpload event handler, but not for the BeforeFileUpload event handler:

    Here is a reference: 

  • Ahh! 
    Very interesting

  • Here's what I ended up with, in AfterFileUpload event handler, many thanks

    ' Test the current object is a 'Document' Object Type = 0	
    If ObjVer.Type = 0 Then	
    	' Test the current object is a 'Document' Class
    	Dim oPropVal : Set oPropVal = CreateObject("MFilesApi.PropertyValues")
    	Set oPropVal = Vault.ObjectPropertyOperations.GetProperties(ObjVer)
        Dim iClassId
        iClassId = Vault.ClassOperations.GetObjectClassIDByAlias("H.Class.Document")
        If oPropVal.SearchForProperty(MFBuiltInPropertyDefClass).TypedValue.GetValueAsLookup.Item = iClassId Then 
    		' Test the document is in WIP workflow state (if not, it would not be editable)
    		Dim wfState : wfState = oPropVal.SearchForProperty(39).TypedValue.DisplayValue ' 39 = Workflow State
    		If wfState = "WIP" Then 
    				' Increment Revision
    				Dim pRev : pRev = Vault.PropertyDefOperations.GetPropertyDefIDByAlias("H.Property.Revision")
    				Dim iRev : iRev = oPropVal.SearchForProperty(pRev).TypedValue.Value
    				iRev = iRev + 1
    				' Update Document object with new Revision
    				Dim propVal : Set propVal = CreateObject("MfilesAPI.PropertyValue")
    				propVal.PropertyDef = pRev 
    				propVal.TypedValue.SetValue MFDataType.MFDatatypeInteger, iRev
    				vault.ObjectPropertyOperations.SetProperty ObjVer, propVal
    		End If ' End the WIP workflow state check
    	End If ' End the Class check
    End If ' End the Type check