AMSX - The xAssets Scripting Language
AMSX is the server-side scripting language at the heart of the xAssets transformation engine.
It provides direct access to the xAssets data model, API, SQL engine, HTTP services, file operations,
and much more, enabling powerful integrations, automations and data processing workflows
without needing to write or host external applications.
Transformations written in AMSX can be triggered from schedules, menu items, record save events,
or externally via the xAssets REST API.
Command Reference
Click any command to view its full documentation, parameters and syntax.
AddCustomFieldAdd a custom specification field to a table if it does not already exist
ApplyDataMappingApply a data mapping lookup to update a field in a temporary table
ApplySurroundTextWrap the result buffer with prefix and suffix text
Base64Encode username:password credentials to Base64 for HTTP Basic Authentication
Base64EncodeEncode a string as a Base64 URL-safe value using a specified character encoding
BatchSqlExecute a batch of SQL commands wrapped in the standard SQL wrapper
BuildUrlConstruct a URL from a base address and a set of query-string parameters
CalculateEvaluate a mathematical or logical expression
CalculatePageCalculate the total number of pages for a paged result set
CallCall an AMSX script file in an isolated scope
CallLocalCall a local AMSX script file, sharing variables and result buffer
CDateParse a string and convert it to an xAssets date
CDateUSParse a string and convert it to a date using US date format
CheckAssetValueAssert that the calculated value of an asset matches an expected figure
CleanColumnsApply a cleaning operation to specified columns in a table
ClearTextDiscard the SQL collected between TEXT and ENDTEXT without executing it
ClosePeriodClose an accounting period so no further depreciation changes are allowed
CodeMark the start of a code block (processed in header)
CommitSleepBeginCommit the current transaction, pause for a short time, then begin a new one
CommitSleepModeConfigure automatic commit-and-sleep behaviour for long-running transactions
CompressCompress a file or folder into a zip archive
ConsolidateTableConsolidate a table by grouping rows on key fields with an aggregate function
ContextSet the context label used in error messages and the log
CopyFileCopy a file from one path to another
CopyFilesCopy multiple files from one folder to another
CopyFolderCopy a folder and its contents to a new location
CreateTableCopyCreate a copy of a database table, optionally seeded with rows
DataManage the output data island used to pass structured data to the browser
Data.AddAdd a named data item to the data island
Data.AddXmlAdd an XML data item to the data island using inline XML
Data.XmlAdd XML data to the data island from the current XML document
DatasetFileToTableLoad a binary dataset file from disk and create temporary tables from its contents
DataSourceSet an XML data source for an xAssets form from the current document
DecompressDecompress a zip archive to a folder or file
DecryptTextStrongDecrypt a string produced by EncryptTextStrong
DeleteOldFilesDelete files older than a specified number of days from a folder
DeleteRecordDelete one or more records from a metadata table
DepreciateCalculate asset depreciation up to a specified date for an accounting period set
DownloadFileDownload a file from a URL and save it to a local path
EditRecordEdit an existing record in a metadata table
EmailToTableDownload emails from a mail server into a temporary table
EmitSqlToFilesWrite SQL query results to files in a folder, one file per row
EmptyFolderDelete all files from a folder, optionally including subfolders
EncryptTextStrongEncrypt a string using strong double-clickable encoding
EndCodeMark the end of a code block (processed in header)
EndTextMark the end of a text block (processed in header)
ExecuteCodeCompile and execute dynamically assembled VB.NET code
ExecuteTextExecute the SQL collected in the current TEXT/ENDTEXT block
ExecuteTextBatchExecute the collected SQL on a dedicated batch-processor connection
ExecuteTextCollRun sql on the collection server
ExecuteTextToDatasetExecute collected SQL and store the result as a dataset, optionally writing it to a file
ExecuteTextToTableExecute collected SQL and bulk insert, update, or delete the results into a table
ExecuteTextValueExecute sql and store the result
ExecuteTextXMLExecute sql and load the XML
ExistsRun a SQL statement and return 1 if a value was found, or 0 if no record exists
ExpectErrorConfigure error-expectation mode used in testing scripts
FieldlistGet the field list for a metadata table
FileExistsCheck whether a file exists and store True or False in the result buffer
FileToTempTable2Load a file into a temporary table using extended permitted folders
FlattenXMLFlatten the AMSX XML document into a single-level structure
FlattenXMLDeepDeep-flatten the AMSX XML document into a single-level structure
FolderExistsCheck whether a folder exists and store True or False in the result buffer
FtpGetDownload a file from an FTP server to the local file system
FtpSendUpload a file to an FTP server
GetAssetValueCalculate the financial value of an asset and store it in the result buffer
GetCodeCopy the Code block content into the result buffer
GetCodeEvalCopy the Code block into the result buffer with variable substitution
GetFileNameExtract the file name portion from a full file path
GetFilePathExtract the directory portion from a full file path
GetFilePathWebExtract the directory or base path from a file path or web URL
GetLicenseXMLLoad the xAssets license XML into the current document
GetNodeRead the inner text of the currently selected XML node
GetParameterLook up a named value from a parallel field-list and value-list
GetTextCopy the raw Text block content into the result buffer
GetVariableRead a variable's raw value into the result buffer, bypassing command parsing
HexToStringConvert a Unicode hex string back to a plain string
HttpGetSend an HTTP GET request and store the response in the result buffer
HttpGetNetSend an HTTP GET request using the .NET HTTP stack with full credential and header support
HttpSendSend an HTTP POST or PUT request and store the response in the result buffer
HttpSendNetSend an HTTP POST or PUT request using the .NET HTTP stack with full credential and header support
InstrFind the position of a substring within a string
IsXMLTest whether a value is valid XML
JsonSelectQuery the active AMSX JSON object using a JSONPath selector expression
JsonSetSet a property or array element in the active AMSX JSON object
JsonToResultSerialise the active AMSX JSON object to a string and store it in the result buffer
JsonToXMLConvert raw JSON to an XML document using Newtonsoft
JsonToXML2Convert JSON in the result buffer to an XML document using the internal JSONParser
JsonToXMLTableConvert a JSON string to XML using explicit record and field path mappings
JsonValueRead a single value from the active AMSX JSON object by key
JsonWebTokenCreate a signed JSON Web Token and store it in the result buffer
LoadJsonParse a JSON string into the AMSX JSON object for subsequent JsonValue or JsonSelect operations
LoadTextFileLoad a text file into the result buffer
LoadXMLParse the result buffer as XML and load it into the AMSX XML buffer
LoadXMLFileLoad an XML file from disk into the AMSX XML buffer
LoadXMLTextParse an inline XML string and load it into the AMSX XML buffer
MakeVariableSqlSafeMark a named variable as SQL-safe so it is inlined rather than parameterised
MergeParamMerge a parameter or XML parameter block into the parameter collection
MergeSqlColumnMerge the first column of a sql statement into a single field
NewRecordCreate a new record in a metadata table
NodeNameReturn the tag name of the currently selected XML node
ParametersDeclare expected script parameters and initialise any that are missing
PositionDepreciationAdvance the depreciation position marker without recalculating depreciation values
PrintLastWrite the current result buffer to the log, preceded by a label
QueryXDML definition block for Query, Script, or Client Script
QueryCacheCache a query result in a temporary table, running it only once per script execution
QueryToXMLRun an xAssets saved query and load the result into the AMSX XML buffer
RecogniseSoftwareMatch raw software inventory records against the known software catalogue
ReplaceReplace occurrences of a string in the result buffer, decoding special tokens first
ReplaceAllReplace all occurrences of a string within a given string
ReplaceFirstReplace the first occurrence of a string within a given string
ReplaceStringReplace all occurrences of a literal string in the result buffer
ReplaceURLRebuild a URL replacing the scheme, host, or port
ResetPasswordReset a user's password and optionally send a notification email
RewindRewind an accounting period, deleting previously calculated depreciation
RunReportRun a saved query report and output it to a file or browser window
SaveNextAssetFlag the engine to save only the first asset encountered during the next XMLSaver run
SaveSpecialRun a SaveSpecial operation using the AMSX XML buffer
SaveSpecial1Run a SaveSpecial operation using the AMSX XML buffer (no argument shift)
SaveSpecial2Run a SaveSpecial operation with XML supplied as an argument
SaveSpecial3Run a SaveSpecial operation with caret-delimited arguments
SaveSpecial4Run a SaveSpecial operation with explicit XML and shifted arguments
SaveSpecialXMLRun a SaveSpecial operation using script input parameters as XML
SaveTextFileSave the result buffer to a text file on the server
SaveTextFileAsciiSave the result buffer to a text file using ASCII encoding
SaveTextFileFromVariableSave the contents of a variable to a text file on the server
SaveTextFilePrivateSave the result buffer to a file in the private customer data area
SaveTextFilePrivateFromVariableSave the value of a variable to a file in the private customer data area
SaveXMLSave the AMSX XML buffer to the database
SaveXMLFileSave the current XML document to a file on the server
SendEmailSend an email to one or more recipients
SerializeSerialise a database table or object into XML, JSON, or AMSX text format
SetSet the result buffer to a fixed value or variable
SetLaunchSet the launch URL or command to be returned to the caller
SetReturnValueCopy the result buffer into the transform's string return value
SetTextExtract the collected SQL/text block into the result buffer
SetThreadPriorityLower the thread priority for this script to avoid affecting system responsiveness
Sha256Compute a SHA-256 hash of a string and return it as a Base64-URL-encoded value
SleepPause script execution for a specified number of milliseconds
SnmpPerform SNMP operations such as reading MIB files
SplitStringSplit a string by a delimiter and return the element at a given position
SqlExecute a SQL statement and place the first value of the result in the result buffer
SqlBatchExecute a SQL statement on the batch processor's dedicated database connection
SqlCsvExecute a SQL statement and return the result as a CSV string
SqlDateExecute a SQL statement and return the result as a date value
SqlInListStore a comma-separated list as a SQL-safe IN list variable
SqlInListValuesStore a list as a SQL-safe parameterised VALUES list for bulk INSERT statements
SqlSetExecute a SQL statement and assign its columns to named variables
SqlSnippetStore a SQL-safe string in a variable for use in SQL statement construction
SqlStatementBuild and execute dynamic SQL statements using a fluent sub-command API
SqlStatement.DumpDump the generated SQL text of a SQL statement variable to the result buffer
SqlStatement.SqlSetExecute a SQL statement variable and assign column values to named AMSX variables
SqlTextOntoXMLOverlay Sql text onto XML
SqlToXMLExecute a SQL statement and load the results into the AMSX XML buffer
StartServiceStart a Windows service if it is currently stopped
StopServiceStop a Windows service if it is currently running
StringToHexConvert a string to its Unicode hex representation
SwitchUserSwitch the current execution context to a different user
SyncDatabaseSynchronise data from a source database into the current database
SyncPeriodTableSynchronise the accounting period table to match the current date
TableExistsCheck whether a database table or temp table exists and return true or false
TableWordExpandExpand and normalise word tokens in a table column using SQL-driven rules
TestRun assertion tests against database table contents
Test.CountAssert that the number of rows in a table matches an expected count
Test.ExistsAssert that at least one row matching a WHERE condition exists in a table
TestQueryValidate that a saved xAssets query executes without errors
TextMark the start of a text block (processed in header)
ThrowRaise an exception and abort the script
TouchUpdate a file's last-modified timestamp to the current time
TrimTrim whitespace or a specific character from a string
TryDeleteAttempt to delete a file, ignoring errors if it cannot be deleted
UnzipNetExtract a zip archive using the .NET ZipFile class
UnzipStringDecompress a Base64-encoded compressed string
URLSetValueSet or update a query-string parameter on a URL
ValueTestAssert that two values are equal, throwing an error if they differ
WaitForDueFilesWait until a minimum number of discovery files are ready to process
WaitForFileExistsWait until a file appears on the file system within a timeout period
WriteJournalsWrite accounting journals for an accounting period set up to a specified date
XmlAddColumnNoTagAdd a column to every row in the XML document without tag conversion
XmlFileToTableLoad an XML dataset file from disk and create temporary tables from its contents
XmlFilterListExtract a comma-separated list of values from the XML document matching a filter
XmlGetRead a field value from the XML document into the result buffer
XmlSetWrite a value into a field node in the XML document
XmlSetNodeWrite a value into a field node of the current XML record (mnod)
XmlTestTest two fields in the XML document for equality and report differences
XmlToCSVConvert the current XML document to a delimited text string
XmlToHtmlConvert the XML buffer to an HTML table string
XmlToJsonConvert the XML buffer to a JSON string
XmlToTempTableLoad the current XML document into a temporary database table
XmlToTempTableAppendAppend the XML buffer to a temporary table, adding rows without recreating the table
ZipNetCompress a file or folder using the .NET ZipFile class
ZipStringCompress a string and return it as a Base64-encoded value