File Functions¶
BuildPath¶
Description
Append a name onto an existing path. The format of the new path is ‘path\name'.
Syntax
Arguments
- path
- A string representing a file path.
- name
- A string of either a subpath or file name.
Example
' Joins a directory and a file name, inserting the
' separator.
BuildPath("C:\IMan\Outbound", %OrderNo & ".csv")
' Returns "C:\IMan\Outbound\SO-10432.csv"
' Through a FileSystem setup, named first. The container
' comes from the setup, so the path is relative to it.
BuildPath("AzureBlob-Archive", "outbound", %OrderNo & ".csv")
' Returns "outbound/SO-10432.csv"
FileExists¶
Description
Returns whether the file specified by the File argument exists.
Syntax
Arguments
- file
- The full path of the file.
Example
FileName¶
Description
Returns the file name from a path.
Syntax
Arguments
- filepath
- The full path of the file.
FilePath¶
Description
Returns the path from a file path.
Syntax
Arguments
- filepath
- The full path of the file.
ReadTextFile¶
Description
Reads the contents of a text file.
Syntax
Arguments
- filepath
- The full path of the file.
- throwonerror
- When set to False the function will return an empty string instead of raising an error when an error occurs either opening or reading the file.
Example
' Reads the whole file as UTF-8. The last argument is
' throwOnError: False returns an empty string for a
' missing or unreadable file and the integration
' continues; True fails the record.
ReadTextFile("C:\IMan\Inbound\" & %OrderNo & ".xml", False)
' Through a FileSystem setup, named first -- here an AWS
' S3 bucket. The bucket comes from the setup, so the path
' is the object key within it.
ReadTextFile("S3-Inbound", "orders/" & %OrderNo & ".xml", True)
WriteBinaryValue¶
Description
Writes the value of a binary field to the specified path. If the file exists it will be overwritten.
Syntax
Arguments
- filepath
- The path to write the field's contents.
- fieldId
- The binary field's name. If the field is not a Binary field type an error will be raised.
Example
' Writes a BINARY field's value to a file -- use it to
' land an attachment that arrived inside the dataset. If
' the field is not set, nothing is written and no error
' is raised.
WriteBinaryValue("C:\IMan\Outbound\" & %OrderNo & ".pdf", "DocumentImage")
' Through a FileSystem setup, named first -- here a
' OneDrive for Business drive.
WriteBinaryValue("OneDrive-Finance", "Invoices/" & %OrderNo & ".pdf", "DocumentImage")
WriteTextFile¶
Description
Writes to a text file. If the file exists it will be overwritten.
Syntax
Arguments
- filepath
- The full path of the file.
- data
- The data to write to the file.