FileLocation

You can use the FileLocation function to return a file path based on entries configured in the File Location form. You can retrieve configured file paths from the File Location form for use in workflows. This function allows centralized management of file and folder locations without hardcoding paths in scripts.

When to use

You can use this function to:

  • Retrieve file paths from central configuration instead of hardcoding paths in scripts.
  • Use different file paths for development, test, and production environments without changing script code.
  • Retrieve paths for imports, exports, attachments, and other file-based workflow operations.

When not to use

You cannot use this function:

  • If file location entries have not been configured. You can use the DefaultValue parameter or check for a null or empty return.
  • In a Multi-Tenant SaaS environment when file paths are not relevant or used.

Syntax

string FileLocation(string LocationType, string LocationName, string UserCode = null, string DefaultValue = null);

Parameters

Parameter Type Required Description
LocationType string Yes The type or category of the location. For example, "WEBREPORTS", "EXPORTS", "IMPORTS")
LocationName string Yes The name of the specific path from File Location form. For example, "XMLWORK", "SOURCE")
UserCode string No The user code for user-specific paths.
Note: If not specified, current user code is used.
DefaultValue string No The default value to return if no file location entry is found.

Return Value

The application returns the configured file path from the File Location form if the operation is successful.

The function resolves the file location hierarchy in the following order:

  1. User-specific entry - The application returns the user-specific path if configured for the specified UserCode.
  2. Default entry - The application returns the default entry (@DFLT) if no user-specific entry exists.
  3. Default value - The application returns the DefaultValue parameter if no file location entry is found.

Prerequisites

You do not need any specific permissions beyond standard access.

Examples

Example 1
Retrieve XML File Path.
// Get path to XML files
string fl = FileLocation("WEBREPORTS", "XMLWORK");
MessageList("XMLWork = " + fl);
Description
This example retrieves the path to XML files. The path is specified in the File Location form for the set type WEBREPORTS with the name XMLWORK.
Example 2
Retrieve multiple paths for report generation.
// Get paths for XML and RPT files
string sFilePathXMLWork = FileLocation("WEBREPORTS", "XMLWORK");
string sFilePathSource = FileLocation("WEBREPORTS", "SOURCE");

// Save XML template
xdTemplate.Save(Path.Combine(sFilePathXMLWork, "FSWB_Formula.xml"));

// Launch web report
ShellAPI($"http://localhost/FsWebReports/Launch.aspx?p1=FSWB_Formula.xml&p2=FORMULA&p3=pdf&p4={Path.Combine(sFilePathSource, "FSWB_Formula_Data.rpt")}");
Description
This example retrieves a path to both XML files and RPT files. These paths are specified in the File Location form. The set type is WEBREPORTS. The name XMLWORK is the path to XML files. The name SOURCE is the path toRPT files.
Note: You can use ObjProperty instead of file location to retrieve the same information.