Need help creating an expression that doesn't overwrite a file.

I’m working on an app and I’m fairly new to AppSheet. The app is simple, when it runs it generates a pdf file with the content submitted on a form. So far is working fine but need help with the following.

One of the fields in the form is used to save the file. Example “Invoice#”. The file gets saved with whatever gets entered in this field (invoice#) field, but here’s the problem if a user runs the app and adds the same invoice# it overwrites the original file. Is there a way to append a number when a file with the same is saved? This way it won’t overwrite any of the files. I know this needs to be added under the “File Name Prefix” but can’t figure it out. Any help will be appreciated.

Thanks

You can add the IDor key Column as Prefix

Welcome to the community!

You can prevent the user from entering the same invoice number by checking if the entered value exists. In the corresponding column, you can add an expression similar to the one below in the "Valid if"field:

NOT(IN([_THIS], tableName[invoice#])

You can set a customer error message like: "Invoice number already exists, please … "

Alternatively you can append a timestamp or a random number to filename before saving the file whether or not another file with the same invoice number exists:

[fileName] & TEXT(NOW(), “yyyymmdd-HHMMSS”

or

[fileName] & UNIQUEID()

1 Like