Skip to content
Update System Global API authored by Connor Quick's avatar Connor Quick
......@@ -41,14 +41,15 @@ addInfoMessage("This is an informational message.");
## `base64Decode(String source)`
**Description:**\
### Description
Returns an ASCII string from the specified base64 string.
**Parameters:**
### Parameters
- `source` (String): The base64 encoded string.
**Usage:**
### Usage
```javascript
let asciiString = base64Decode("SGVsbG8gd29ybGQ=");
......@@ -56,14 +57,15 @@ let asciiString = base64Decode("SGVsbG8gd29ybGQ=");
## `base64Encode(String source)`
**Description:**\
### Description
Creates a base64 string from the specified string.
**Parameters:**
### Parameters
- `source` (String): The string to encode to base64.
**Usage:**
### Usage
```javascript
let base64String = base64Encode("Hello world");
......@@ -71,10 +73,11 @@ let base64String = base64Encode("Hello world");
## `beginningOfLastMonth()`
**Description:**\
### Description
Returns the date and time for the beginning of last month in GMT.
**Usage:**
### Usage
```javascript
let beginningLastMonth = beginningOfLastMonth();
......@@ -82,10 +85,11 @@ let beginningLastMonth = beginningOfLastMonth();
## `beginningOfLastWeek()`
**Description:**\
### Description
Returns the date and time for the beginning of last week in GMT.
**Usage:**
### Usage
```javascript
let beginningLastWeek = beginningOfLastWeek();
......@@ -93,10 +97,11 @@ let beginningLastWeek = beginningOfLastWeek();
## `beginningOfNextMonth()`
**Description:**\
### Description
Returns the date and time for the beginning of next month in GMT.
**Usage:**
### Usage
```javascript
let beginningNextMonth = beginningOfNextMonth();
......@@ -104,10 +109,11 @@ let beginningNextMonth = beginningOfNextMonth();
## `beginningOfNextWeek()`
**Description:**\
### Description
Returns the date and time for the beginning of next week in GMT.
**Usage:**
### Usage
```javascript
let beginningNextWeek = beginningOfNextWeek();
......@@ -115,10 +121,11 @@ let beginningNextWeek = beginningOfNextWeek();
## `beginningOfNextYear()`
**Description:**\
### Description
Returns the date and time for the beginning of next year in GMT.
**Usage:**
### Usage
```javascript
let beginningNextYear = beginningOfNextYear();
......@@ -126,10 +133,11 @@ let beginningNextYear = beginningOfNextYear();
## `beginningOfThisMonth()`
**Description:**\
### Description
Returns the date and time for the beginning of this month in GMT.
**Usage:**
### Usage
```javascript
let beginningThisMonth = beginningOfThisMonth();
......@@ -137,10 +145,11 @@ let beginningThisMonth = beginningOfThisMonth();
## `beginningOfThisQuarter()`
**Description:**\
### Description
Returns the date and time for the beginning of this quarter in GMT.
**Usage:**
### Usage
```javascript
let beginningThisQuarter = beginningOfThisQuarter();
......@@ -148,10 +157,11 @@ let beginningThisQuarter = beginningOfThisQuarter();
## `beginningOfThisWeek()`
**Description:**\
### Description
Returns the date and time for the beginning of this week in GMT.
**Usage:**
### Usage
```javascript
let beginningThisWeek = beginningOfThisWeek();
......@@ -159,10 +169,11 @@ let beginningThisWeek = beginningOfThisWeek();
## `beginningOfThisYear()`
**Description:**\
### Description
Returns the date and time for the beginning of this year in GMT.
**Usage:**
### Usage
```javascript
let beginningThisYear = beginningOfThisYear();
......@@ -170,14 +181,15 @@ let beginningThisYear = beginningOfThisYear();
## `daysAgo(Number days)`
**Description:**\
### Description
Returns the date and time for a specified number of days ago.
**Parameters:**
### Parameters
- `days` (Number): The number of days ago.
**Usage:**
### Usage
```javascript
let daysAgo = daysAgo(3);
......@@ -185,14 +197,15 @@ let daysAgo = daysAgo(3);
## `daysAgoEnd(Number days)`
**Description:**\
### Description
Returns the date and time for the end of the day a specified number of days ago.
**Parameters:**
### Parameters
- `days` (Number): The number of days ago.
**Usage:**
### Usage
```javascript
let endOfDay = daysAgoEnd(3);
......@@ -200,14 +213,15 @@ let endOfDay = daysAgoEnd(3);
## `daysAgoStart(Number days)`
**Description:**\
### Description
Returns the date and time for the beginning of the day a specified number of days ago.
**Parameters:**
### Parameters
- `days` (Number): The number of days ago.
**Usage:**
### Usage
```javascript
let startOfDay = daysAgoStart(3);
......@@ -215,14 +229,15 @@ let startOfDay = daysAgoStart(3);
## `debug(String message)`
**Description:**\
### Description
Writes a debug message to the system log.
**Parameters:**
### Parameters
- `message` (String): The debug message to log.
**Usage:**
### Usage
```javascript
debug("This is a debug message");
......@@ -230,10 +245,11 @@ debug("This is a debug message");
## `endOfLastMonth()`
**Description:**\
### Description
Returns the date and time for the end of last month in GMT.
**Usage:**
### Usage
```javascript
let endOfLastMonth = endOfLastMonth();
......@@ -241,10 +257,11 @@ let endOfLastMonth = endOfLastMonth();
## `endOfLastWeek()`
**Description:**\
### Description
Returns the date and time for the end of last week in GMT.
**Usage:**
### Usage
```javascript
let endOfLastWeek = endOfLastWeek();
......@@ -252,10 +269,11 @@ let endOfLastWeek = endOfLastWeek();
## `endOfLastYear()`
**Description:**\
### Description
Returns the date and time for the end of last year in GMT.
**Usage:**
### Usage
```javascript
let endOfLastYear = endOfLastYear();
......@@ -263,10 +281,11 @@ let endOfLastYear = endOfLastYear();
## `endOfNextMonth()`
**Description:**\
### Description
Returns the date and time for the end of next month in GMT.
**Usage:**
### Usage
```javascript
let endOfNextMonth = endOfNextMonth();
......@@ -274,10 +293,11 @@ let endOfNextMonth = endOfNextMonth();
## `endOfNextWeek()`
**Description:**\
### Description
Returns the date and time for the end of next week in GMT.
**Usage:**
### Usage
```javascript
let endOfNextWeek = endOfNextWeek();
......@@ -285,10 +305,11 @@ let endOfNextWeek = endOfNextWeek();
## `endOfNextYear()`
**Description:**\
### Description
Returns the date and time for the end of next year in GMT.
**Usage:**
### Usage
```javascript
let endOfNextYear = endOfNextYear()
......@@ -296,10 +317,11 @@ let endOfNextYear = endOfNextYear()
## `endOfThisMonth()`
**Description:**\
### Description
Returns the date and time for the end of this month in GMT.
**Usage:**
### Usage
```javascript
let endOfThisMonth = endOfThisMonth();
......@@ -307,10 +329,11 @@ let endOfThisMonth = endOfThisMonth();
## `endOfThisQuarter()`
**Description:**\
### Description
Returns the date and time for the end of this quarter in GMT.
**Usage:**
### Usage
```javascript
let endOfThisQuarter = endOfThisQuarter();
......@@ -318,10 +341,11 @@ let endOfThisQuarter = endOfThisQuarter();
## `endOfThisWeek()`
**Description:**\
### Description
Returns the date and time for the end of this week in GMT.
**Usage:**
### Usage
```javascript
let endOfThisWeek = endOfThisWeek();
......@@ -329,10 +353,11 @@ let endOfThisWeek = endOfThisWeek();
## `endOfThisYear()`
**Description:**\
### Description
Returns the date and time for the end of this year in GMT.
**Usage:**
### Usage
```javascript
let endOfThisYear = endOfThisYear();
......@@ -340,14 +365,15 @@ let endOfThisYear = endOfThisYear();
## `error(String message)`
**Parameters:**
### Parameters
- `message` (String): The error message to write to the system log.
**Description:**\
### Description
Writes an error message to the system log.
**Usage:**
### Usage
```javascript
error("This is an error message");
......@@ -355,7 +381,7 @@ error("This is an error message");
## `eventQueue(String name, Object instance, String parm1, String parm2, String queue)`
**Parameters:**
### Parameters
- `name` (String): Name of the event.
- `instance` (Object): An instance object.
......@@ -363,10 +389,11 @@ error("This is an error message");
- `parm2` (String): The second parameter.
- `queue` (String): Name of the queue.
**Description:**\
### Description
Queues an event for the event manager.
**Usage:**
### Usage
```javascript
eventQueue("eventName", instanceObject, "parameter1", "parameter2", "queueName");
......@@ -374,7 +401,7 @@ eventQueue("eventName", instanceObject, "parameter1", "parameter2", "queueName")
## `eventQueueScheduled(String name, Object instance, String parm1, String parm2, Object expiration)`
**Parameters:**
### Parameters
- `name` (String): Name of the event.
- `instance` (Object): An instance object.
......@@ -382,10 +409,11 @@ eventQueue("eventName", instanceObject, "parameter1", "parameter2", "queueName")
- `parm2` (String): The second parameter.
- `expiration` (Object): The expiration object.
**Description:**\
### Description
Queues an event in the event manager. The passed in event schedule information is stored in the Events \[sys_events\] table.
**Usage:**
### Usage
```javascript
eventQueueScheduled("eventName", instanceObject, "parameter1", "parameter2", expirationObject);
......@@ -393,10 +421,11 @@ eventQueueScheduled("eventName", instanceObject, "parameter1", "parameter2", exp
## `generateGUID()`
**Description:**\
### Description
Generates a GUID that can be used when a unique identifier is required.
**Usage:**
### Usage
```javascript
let guid = generateGUID();
......@@ -404,10 +433,11 @@ let guid = generateGUID();
## `getErrorMessages()`
**Description:**\
### Description
Returns the error messages that were added by addErrorMessage() for the session.
**Usage:**
### Usage
```javascript
let errorMessages = getErrorMessages();
......@@ -415,15 +445,16 @@ let errorMessages = getErrorMessages();
## `getProperty(String key, Object alt)`
**Parameters:**
### Parameters
- `key` (String): The key of the system property.
- `alt` (Object): The alternate value to return if the property is not found.
**Description:**\
### Description
Gets the value of a system property from sys_properties. If the property is not found, returns an alternate value.
**Usage:**
### Usage
```javascript
let propertyValue = getProperty("propertyKey", "alternateValue");
......@@ -431,10 +462,11 @@ let propertyValue = getProperty("propertyKey", "alternateValue");
## `getTimeZoneName()`
**Description:**\
### Description
Returns the name of the time zone associated with the current user.
**Usage:**
### Usage
```javascript
let timeZoneName = getTimeZoneName();
......@@ -442,10 +474,11 @@ let timeZoneName = getTimeZoneName();
## `getUrlOnStack()`
**Description:**\
### Description
Gets the current URI for the session.
**Usage:**
### Usage
```javascript
let url = getUrlOnStack();
......@@ -453,10 +486,11 @@ let url = getUrlOnStack();
## `getUser()`
**Description:**\
### Description
Returns a reference to the scoped SystemUser object for the current user.
**Usage:**
### Usage
```javascript
let user = getUser();
......@@ -464,10 +498,11 @@ let user = getUser();
## `getUserDisplayName()`
**Description:**\
### Description
Gets the display name of the current user.
**Usage:**
### Usage
```javascript
let displayName = getUserDisplayName();
......@@ -475,10 +510,11 @@ let displayName = getUserDisplayName();
## `getUserID()`
**Description:**\
### Description
Gets the id of the current user.
**Usage:**
### Usage
```javascript
let userId = getUserID();
......@@ -486,10 +522,11 @@ let userId = getUserID();
## `getUserName()`
**Description:**\
### Description
Gets the user name, or user id, of the current user.
**Usage:**
### Usage
```javascript
let userName = getUserName();
......@@ -497,14 +534,15 @@ let userName = getUserName();
## `hasRole(role)`
**Description:**\
### Description
Determines if the current user has the specified role.
**Parameters:**
### Parameters
- `role`: Object - The role to check for.
**Usage:**
### Usage
```javascript
let hasRoleAdmin = hasRole('admin');
......@@ -512,14 +550,15 @@ let hasRoleAdmin = hasRole('admin');
## `hoursAgo(hours)`
**Description:**\
### Description
Returns the date and time for a specified number of hours ago.
**Parameters:**
### Parameters
- `hours`: Number - The number of hours ago.
**Usage:**
### Usage
```javascript
let timeFewHoursAgo = hoursAgo(3);
......@@ -527,14 +566,15 @@ let timeFewHoursAgo = hoursAgo(3);
## `hoursAgoEnd(hours)`
**Description:**\
### Description
Returns the date and time for the end of the hour a specified number of hours ago.
**Parameters:**
### Parameters
- `hours`: Number - The number of hours ago.
**Usage:**
### Usage
```javascript
let timeHoursAgoEnd = hoursAgoEnd(3);
......@@ -542,14 +582,15 @@ let timeHoursAgoEnd = hoursAgoEnd(3);
## `hoursAgoStart(hours)`
**Description:**\
### Description
Returns the date and time for the start of the hour a specified number of hours ago.
**Parameters:**
### Parameters
- `hours`: Number - The number of hours ago.
**Usage:**
### Usage
```javascript
let timeHoursAgoStart = hoursAgoStart(3);
......@@ -557,14 +598,15 @@ let timeHoursAgoStart = hoursAgoStart(3);
## `include(name)`
**Description:**\
### Description
Provides a safe way to call a script include from the sandbox, allowing only the inclusion of trusted scripts.
**Parameters:**
### Parameters
- `name`: String - The name of the script to include.
**Usage:**
### Usage
```javascript
include('myScript');
......@@ -572,14 +614,15 @@ include('myScript');
## `info(message)`
**Description:**\
### Description
Writes an info message to the system log.
**Parameters:**
### Parameters
- `message`: String - The message to log.
**Usage:**
### Usage
```javascript
info('This is an info message.');
......@@ -587,14 +630,15 @@ info('This is an info message.');
## `minutesAgoEnd(minutes)`
**Description:**\
### Description
Returns the date and time for the end of the minute a specified number of minutes ago.
**Parameters:**
### Parameters
- `minutes`: Number - The number of minutes ago.
**Usage:**
### Usage
```javascript
let timeMinutesAgoEnd = minutesAgoEnd(30);
......@@ -602,14 +646,15 @@ let timeMinutesAgoEnd = minutesAgoEnd(30);
## `minutesAgoStart(minutes)`
**Description:**\
### Description
Returns the date and time for the start of the minute a specified number of minutes ago.
**Parameters:**
### Parameters
- `minutes`: Number - The number of minutes ago.
**Usage:**
### Usage
```javascript
let timeMinutesAgoStart = minutesAgoStart(30);
......@@ -617,14 +662,15 @@ let timeMinutesAgoStart = minutesAgoStart(30);
## `monthsAgo(months)`
**Description:**\
### Description
Returns the date and time for a specified number of months ago.
**Parameters:**
### Parameters
- `months`: Number - The number of months ago.
**Usage:**
### Usage
```javascript
let timeMonthsAgo = monthsAgo(3);
......@@ -632,14 +678,15 @@ let timeMonthsAgo = monthsAgo(3);
## `monthsAgoStart(months)`
**Description:**\
### Description
Returns the date and time for the start of the month a specified number of months ago.
**Parameters:**
### Parameters
- `months`: Number - The number of months ago.
**Usage:**
### Usage
```javascript
let timeMonthsAgoStart = monthsAgoStart(3);
......@@ -647,14 +694,15 @@ let timeMonthsAgoStart = monthsAgoStart(3);
## `nil(o)`
**Description:**\
### Description
Queries an object and returns true if the object is null, undefined, or contains an empty string.
**Parameters:**
### Parameters
- `o`: Object - The object to query.
**Usage:**
### Usage
```javascript
let isNull = nil(myObject);
......@@ -662,14 +710,15 @@ let isNull = nil(myObject);
## `quartersAgoEnd(quarters)`
**Description:**\
### Description
Returns the date and time for the last day of the quarter for a specified number of quarters ago.
**Parameters:**
### Parameters
- `quarters`: Number - The number of quarters ago.
**Usage:**
### Usage
```javascript
let timeQuartersAgoEnd = quartersAgoEnd(2);
......@@ -677,14 +726,15 @@ let timeQuartersAgoEnd = quartersAgoEnd(2);
## `quartersAgoStart(quarters)`
**Description:**\
### Description
Returns the date and time for the first day of the quarter for a specified number of quarters ago.
**Parameters:**
### Parameters
- `quarters`: Number - The number of quarters ago.
**Usage:**
### Usage
```javascript
let timeQuartersAgoStart = quartersAgoStart(2);
......@@ -692,16 +742,17 @@ let timeQuartersAgoStart = quartersAgoStart(2);
## `setProperty(key, value, description)`
**Description:**\
### Description
Sets the specified key to the specified value if the property is within the script's scope.
**Parameters:**
### Parameters
- `key`: String - The property key.
- `value`: String - The property value.
- `description`: String - The property description.
**Usage:**
### Usage
```javascript
setProperty('myKey', 'myValue', 'This is a property description');
......@@ -709,14 +760,15 @@ setProperty('myKey', 'myValue', 'This is a property description');
## `setRedirect(o)`
**Description:**\
### Description
Sets the redirect URI for this transaction, which then determines the next page the user will see.
**Parameters:**
### Parameters
- `o`: Object - The URI to redirect to.
**Usage:**
### Usage
```javascript
setRedirect(myURI);
......@@ -724,14 +776,15 @@ setRedirect(myURI);
## `tableExists(name)`
**Description:**\
### Description
Determines if a database table exists.
**Parameters:**
### Parameters
- `name`: String - The name of the table.
**Usage:**
### Usage
```javascript
let doesTableExist = tableExists('myTable');
......@@ -739,14 +792,15 @@ let doesTableExist = tableExists('myTable');
## `urlDecode(url)`
**Description:**\
### Description
Replaces UTF-8 encoded characters with ASCII characters.
**Parameters:**
### Parameters
- `url`: String - The URL to decode.
**Usage:**
### Usage
```javascript
let decodedUrl = urlDecode('https%3A%2F%2Fexample.com');
......@@ -754,14 +808,15 @@ let decodedUrl = urlDecode('https%3A%2F%2Fexample.com');
## `urlEncode(url)`
**Description:**\
### Description
Encodes non-ASCII characters, unsafe ASCII characters, and spaces so the returned string can be used on the Internet. Uses UTF-8 encoding. Uses percent (%) encoding.
**Parameters:**
### Parameters
- `url`: String - The URL to encode.
**Usage:**
### Usage
```javascript
let encodedUrl = urlEncode('https://example.com');
......@@ -769,14 +824,15 @@ let encodedUrl = urlEncode('https://example.com');
## `warn(message)`
**Description:**\
### Description
Writes a warning message to the system log.
**Parameters:**
### Parameters
- `message`: String - The warning message to log.
**Usage:**
### Usage
```javascript
warn('This is a warning message');
......@@ -784,14 +840,15 @@ warn('This is a warning message');
## `xmlToJSON(xmlString)`
**Description:**\
### Description
Takes an XML string and returns a JSON object.
**Parameters:**
### Parameters
- `xmlString`: String - The XML string to convert.
**Usage:**
### Usage
```javascript
let jsonObject = xmlToJSON('<root><test>value</test></root>');
......@@ -799,14 +856,15 @@ let jsonObject = xmlToJSON('<root><test>value</test></root>');
## `yearsAgo(years)`
**Description:**\
### Description
Returns a date and time for a certain number of years ago.
**Parameters:**
### Parameters
- `years`: Number - The number of years ago.
**Usage:**
### Usage
```javascript
let timeYearsAgo = yearsAgo(5);
......@@ -814,10 +872,11 @@ let timeYearsAgo = yearsAgo(5);
## `yesterday()`
**Description:**\
### Description
Returns yesterday's time (24 hours ago).
**Usage:**
### Usage
```javascript
let timeYesterday = yesterday();
......
......