Attachments and documents

Can I get the file name of an uploaded attachment into a field?

Formulas can't read an attachment's file name. Copy it with an integration that maps the attachment's Name into a text field, or with a button script.

How-to

Short answer: Not with a formula. Use an integration that copies the attachment's Name into a text field after submission, or a button that runs a short script.

Why it happens

  • An attachment field holds a list of files, not text. A text formula fails with "Expression is returning 'JSONList' Allowed Types are 'String'".
  • Field events can't be added to attachment fields, so nothing runs when a file is uploaded.

How to fix it

With an integration:

  1. Create an integration with a Kissflow Process trigger such as When a draft item is submitted.
  2. Add Update an item for the same item.
  3. Map the attachment field's Name for the first file (index 0) into a text field.
  4. Test the action, then turn on the integration.

With a button on the form:

  1. Add a button and give it an On Click event.
  2. Use a script that reads the field and writes the name, for example: let file = await kf.context.getField("Document"); kf.context.updateField({"Document_name": file[0]["name"]})
  3. Replace Document and Document_name with your field IDs.

Tip

The integration fills the field after the item is submitted. The button fills it while the user is still on the form.

Related answers