Remove File from Multi-File When in Specific Workflow

I am creating a new workflow to deal with QAQC checklists. Once a new revision of the QAQC is required, in the transition between QAQC Approved and Closed and Update QAQC checklist for the multi-file to be emptied so the end user can add the new revision of the file. Does anyone have any ideas as to how to achieve this? 

Parents
  • You should be able to do it with VBScript on that transition.

    CoPilot thinks this script is good enough to delete files in your case;

    ' Define the object to delete files from
    Dim ObjVer
    Set ObjVer = CreateObject("MFilesAPI.ObjVer")
    Self = ObjVer.ID
    
    ObjVer.SetIDs 0, Self, -1
    
    ' Retrieve the object version
    Dim ObjVerVersion
    Set ObjVerVersion = Vault.ObjectOperations.GetLatestObjVer(ObjVer, True)
    
    ' Retrieve all files in the object
    Dim ObjFiles
    Set ObjFiles = Vault.ObjectFileOperations.GetFiles(ObjVerVersion.ObjID)
    
    Dim i
    For i = 1 To ObjFiles.Count
        ' Delete each file
        Vault.ObjectFileOperations.DeleteFileInObject(ObjVerVersion.ObjID, ObjFiles.Item(i-1).FileVer)
    Next

    looks.... good enough ? Slight smile
Reply
  • You should be able to do it with VBScript on that transition.

    CoPilot thinks this script is good enough to delete files in your case;

    ' Define the object to delete files from
    Dim ObjVer
    Set ObjVer = CreateObject("MFilesAPI.ObjVer")
    Self = ObjVer.ID
    
    ObjVer.SetIDs 0, Self, -1
    
    ' Retrieve the object version
    Dim ObjVerVersion
    Set ObjVerVersion = Vault.ObjectOperations.GetLatestObjVer(ObjVer, True)
    
    ' Retrieve all files in the object
    Dim ObjFiles
    Set ObjFiles = Vault.ObjectFileOperations.GetFiles(ObjVerVersion.ObjID)
    
    Dim i
    For i = 1 To ObjFiles.Count
        ' Delete each file
        Vault.ObjectFileOperations.DeleteFileInObject(ObjVerVersion.ObjID, ObjFiles.Item(i-1).FileVer)
    Next

    looks.... good enough ? Slight smile
Children
No Data