Check filename and file extension on upload in an event handler

Hi all, I need to run some checks on uploaded documents based on file extension and filename

We're using the Classic Web client

Basic code below, it works when it's a Precondition in a workflow, using either Desktop or Classic Web clients

But, I now need to move it to an Event Handler for reasons (BeforeFileUpload, or BeforeCreateNewObjectFinalize), and when I do, it stops working in Classic Web, although continues to work in Desktop

' Test filetype on upload to Reports document classes. Precondition in Reports workflow
' Needs an IF to allow/disallow certain filetypes if implemented

Dim oObjectFiles : Set oObjectFiles = Vault.ObjectFileOperations.GetFiles(ObjVer)
Dim oObjectFile : Set oObjectFile = oObjectFiles.Item(1)
Dim strExtension
strExtension = oObjectFile.Extension

' Get file extension

Err.Raise MFScriptCancel, "Filename: '" & oObjectFile.Title & ". Filetype: '" & strExtension & "'"

It's this part

Dim oObjectFiles : Set oObjectFiles = Vault.ObjectFileOperations.GetFiles(ObjVer)
Dim oObjectFile : Set oObjectFile = oObjectFiles.Item(1)

It doesn't work when I'm uploading as a single file (not MFD) into a doc class, using the Classic Web client. I think perhaps the GetFiles isn't the right approach for a single file, or the actual file doesn't "exist" yet on the vault at the point I'm trying to run this... not sure
Any ideas please?
Many thanks
Parents Reply Children
  • Additionally, as I said earlier, you may struggle to get a lot of people replying to this as the classic web client has been considered legacy for some time now.  The reality of that is that, assuming it works correctly in the new web client, it's difficult to maintain knowledge around some of these edge cases.

    I notice from your profile that it states that you're a partner, but I cannot see any details as to your company name.  I assume that's on purpose.  For now I will maybe highlight that as a partner you can reach out to the support team for an "implementation support request" which may be a way to get more targeted support.  Alternatively your partner account manager may be able to assist further.