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

Increment revison on file drag n drop

Hi all, related to my other query
https://community.m-files.com/forums-1552881334/f/m-files-api/6494/replacing-files-within-mfd-on-drag-drop-action

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

Parents Reply Children
  • 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