0

fileUrl

To return the URL of a specific file from a record

This function allows you to directly link to a specific file (e.g. an image or attachment) stored in a record—perfect for use in PDFs, emails, or external apps. Unlike shareFile(), the fileUrl() function is designed for use in formula fields and generates permanent links that work outside the database as well.

ℹ️ fileUrl() can't be used in triggers or within do as server, do as transaction, or do as deferred blocks.

The generated URL includes information about the currently logged-in user, which is only available on the client side. Server-side code doesn't have access to this, which is why fileUrl() doesn't work there.

Syntax

file(nid, string)

Return

link

Examples

ℹ️ In the URL, {API-KEY} is a placeholder for the actual API key, which has been removed for security reasons.

To generate the URL of a file (for example, an uploaded image named "Cave Entrance Waterfall.jpg"), the file name must be extracted from the file path. This can be done using a regular expression.

Example 1: Directly in the function call

fileUrl(this, extractx(text(Image), ".+/(.+)", "$1"))

This expression extracts the file name from the full file path using a regular expression.

The pattern .+/(.+) finds the last forward slash / and returns everything after it—the actual file name.

Result: https://dbde0149.ninox.com/t3gDkNhdoqf2sTmAR/dd0usv6i6cet/files/get/O2/Cave%20Entrance%20Waterfall.jpg?T=1742980446305&XT=USER-{API-KEY}

Example 2: More readable with an intermediate step

let fileName := extractx(text(Image), "[^/]+$");
fileUrl(this, fileName)

This version is cleaner and easier to read.

First, the file name is extracted using extractx(text(Image), "[^/]+$"), which captures everything after the last slash.

The pattern [^/]+$ means: "Find all characters that are not a slash, at the end of the string."

Result: https://dbde0149.ninox.com/t3gDkNhdoqf2sTmAR/dd0usv6i6cet/files/get/O2/Cave%20Entrance%20Waterfall.jpg?T=1742980446305&XT=USER-{API-KEY}

See also

extractx extract a string from a given text using a regular expression.

shareFile returns a URL of a specific file.

Reply

null