Community

Connect with us and enhance your M-Files experience using Extension Kit for M-Files. Here’s how to get started.

Notifications
Clear all

[Solved] Validation rule for file types

0
Topic starter

Dear Community,

Currently we are using a script along with a value list of disallowed file extension (see below).
I would like to replace this script with an EK validation rule.

My question now is, which property can I use to filter for the file extension .

The Property Filname unfortunately does not contain the file extension.
Does anyone here have an idea of what could be used?

 

Thanks in advance for your ideas

 

Kind regards,

Jeremias

Option Explicit


Dim iForbiddenExtensionListID, oListForbiddenExtensions
Dim oFiles, oFile, oForbiddenExtension

Set oFiles = Vault.ObjectFileOperations.GetFiles(ObjVer)
iForbiddenExtensionListID = Vault.ValueListOperations.GetValueListIDByAlias("list.VerboteneDateiendungFuerUpload")
Set oListForbiddenExtensions = Vault.ValueListItemOperations.GetValueListItems(iForbiddenExtensionListID)


If oFiles.Count > 0 Then
	For Each oFile in oFiles
		For Each oForbiddenExtension in oListForbiddenExtensions
			If lcase(oFile.Extension) = lcase(oForbiddenExtension.Name) Then
				Err.Raise MFScriptCancel, 	"Upload der Datei '" & oFile.Title & "." & oFile.Extension & " nicht möglich." & vbCrlf & _
											"Der Upload von Dateien mit der Dateiendung ." & oFile.Extension & " ist verboten."
			End If
		Next 
	Next
End If
Topic Tags
1 Answer
0

Hi @jerry,

Instead of using script, you can achieve this by adding an Extended Auto Property rule where you use <<EXTENSION(‘*’)>> to save the extension of your file to a new property:

image

Then, set up Validation rules to check whether any of the extensions are on your disallowed list. Currently, <<EXTENSION(‘*’)>> works only with single-file objects, not multi-file ones. Still, I hope this works for you. Let me know if you need any further assistance. 

Best regards,

Nika

Jeremias Zirngast Jeremias Zirngast Topic starter 04/02/2025 4:15 pm

Hi @nikatilic 
Thank you very much for your detailed answer!

Kind regards

Jeremias

Answer

WATCH THE WEBINAR

Introducing Extension Kit Document AI: Add-on for AI-driven Document Management