🆕removeFile
To securely remove a file from a field or record.
This function removes a file by specifying either:
A
file
object that contains the necessary information (nid
and the file name).nid
and the file name as separate parameters.
The file
object can either come from an Image field or be created using the file(this, "Name")
function.
Caution: When using this function on native apps (iOS, iPadOS, macOS, Android), it must be enclosed in a do as server
code block within the formula editor.
Syntax
removeFile(file, string)
removeFile(nid, string, string)
Return
void
Note: When using the removeFile
function on an Image field (removeFile(file)
), the Image field itself is not automatically updated. This behavior is intentional.
To fully clear the file reference from an Image field, you need to manually set that Image field to null
using scripting, such as:
This ensures that the file is removed and the field is properly cleared.
Examples
Use
removeFile(file)
to remove an image attached to a record and displayed in an Image field:
Result: The image is removed from the record, and the Image field is set to empty.
Use
removeFile(nid, fileName)
to remove a PDF attached to a record:
Result: The PDF "Offer_0724.pdf" is removed from the record.
Note: You can use loops to remove multiple files in the same operation, though the process may be slow.
See also
renameFile
, which renames a file in a field or record.
importFile
, which imports a file from a URL and saves it as an attachment of a record.
shareFile
, which returns a URL of a specific file.
Last updated