System Methods

Call Methods

System

System.LogLocation()

call System.LogLocation("Work order started");

Logs the users GPS location with a comment. Logging will only happen if the user accepts location usage in the device and the application parameters allow it. The actual logging of the users location will happen asynchronously after the procedure successfully completes. This makes sure the client database is not locked for long periods of time.

System.CreateGuid()

call System.CreateGuid() into MyGuid;

Generates and returns a new GUID that contains 32 alphanumeric characters. For example, 86DFA50C48F64A30918D76DC81B16E97.

System.GetParameter()

call System.GetParameter("MyParameter") into MyVariable;

Gets an application parameter value for a parameter defined in the app model. The parameter value can be changed in the Application Parameters screen in EE.

Lists

List.Add(List list, T item);

// variable Steps List<Structure(SurveyStep)>;
// variable Item Structure(SurveyStep);
call List.Add(Steps, Item);

Adds an item to a list variable.

List.Remove(List list, T item);

// variable Steps List<Structure(SurveyStep)>;
// variable Item Structure(SurveyStep);
call List.Remove(Steps, Item);

Removes an item from a list variable.

List.Clear(List list);

// variable Steps List<Structure(SurveyStep)>;
call List.Add(Steps);

Removes all items from a list variable.

List.Count(List list) : Integer;

// variable Steps List<Structure(SurveyStep)>;
// variable ListCount Integer;
call List.Count(Steps) into ListCount;

Adds an item to a list variable.

List.Get(List list, Integer index) : T;

// variable Names List<Text>;
// variable Name Text;
call List.Get(Names, 5) into Name;

Returns an item at the specified zero based index in the list.

List.IndexOf(List list, T item) : Integer;

// variable Names List<Text>;
// variable Index Integer;
call List.IndexOf(Names, "John") into Index;

Returns the zero based index of an item within a list. Returns < 0 if the item is not found.

Dates and Times

DateTime.Timestamp(): Timestamp

call DateTime.Timestamp() into Result;

Gets the current timestamp.

DateTime.Timestamp( Integer year, Integer month, Integer day, Integer hours, Integer mins, Integer secs) : Timestamp

call DateTime.Timestamp(2018, 4, 18, 12, 10, 0) into Result;

Creates a timestamp from the supplied parameters.

DateTime.Date() : Date

call DateTime.Date() into Result;

Gets the current date.

DateTime.Date(Timestamp ts) : Date

call DateTime.Date(Attrib) into Result;

Returns the timestamp with the time portion set to 00:00:00.

DateTime.Date(Integer year, Integer month, Integer day) : Date

call DateTime.Date(2018, 4, 18) into Result;

Creates a date from the supplied parameters.

DateTime.Time(Timestamp ts) : Time

call DateTime.Time(Attrib) into Result;

Returns the time from a timestamp.

DateTime.Time(Integer hours, Integer mins, Integer secs) : Time

call DateTime.Time(12, 10, 0) into Result;

Creates a time from the supplied parameters.

DateTime.AddYears(Timestamp ts, Integer years) : Timestamp

call DateTime.AddYears(Attrib, 2) into Result;

Adds years to the supplied timestamp.

DateTime.AddMonths(Timestamp ts, Integer months) : Timestamp

call DateTime.AddMonths(Attrib, 3) into Result;

Adds months to the supplied timestamp.

DateTime.AddDays(Timestamp ts, Number days) : Timestamp

call DateTime.AddDays(Attrib, 3) into Result;
call DateTime.AddDays(Attrib, 3.4) into Result;

Adds days to the supplied timestamp. Fractional days are supported.

DateTime.AddHours(Timestamp ts, Number hours) : Timestamp

call DateTime.AddHours(Attrib, 3) into Result;
call DateTime.AddHours(Attrib, 3.4) into Result;

Adds hours to the supplied timestamp. Fractional hours are supported.

DateTime.AddMinutes(Timestamp ts, Number minutes) : Timestamp

call DateTime.AddMinutes(Attrib, 3) into Result;
call DateTime.AddMinutes(Attrib, 3.4) into Result;

Adds minutes to the supplied timestamp. Fractional minutes are supported.

DateTime.AddSeconds(Timestamp ts, Integer seconds) : Timestamp

call DateTime.AddMinutes(Attrib, 30) into Result;

Adds seconds to the supplied timestamp.

DateTime.DifferenceInDays(Timestamp a, Timestamp a) : Number

call DateTime.DifferenceInDays(AttribA, AttribB) into Result;

Calculated the difference between two timestamps in days as a fractional number.

DateTime.DifferenceInHours(Timestamp a, Timestamp a) : Number

call DateTime.DifferenceInHours(AttribA, AttribB) into Result;

Calculated the difference between two timestamps in hours as a fractional number.

String

String.Length(string) : Number

call String.Length("abcde") into Result; // "5"

Returns the length of a string

String.Trim(string) : Text

String.Trim(string, char) : Text

String.TrimStart(string) : Text

String.TrimStart(string, char) : Text

String.TrimEnd(string) : Text

String.TrimEnd(string, char) : Text

call String.Trim(" MyValue ") into Result; // "MyValue"
call String.Trim("#MyValue ", "#") into Result; // "MyValue "
call String.Trim("MyValue ", null) into Result; // null
call String.Trim("MyValue ", "") into Result; // null
call String.TrimEnd("#MyValue#", "#") into Result; // "#MyValue"

Removes characters from the start or end of strings Note: if the char parameter is null or empty the Trim functions will return null.

String.ToUpper(string) : Text

call String.ToUpper("MyValue") into Result; // "MYVALUE"

Converts a string to upper case

String.ToLower(string) : Text

call String.ToLower("MyValue") into Result; // "myvalue"

Converts a string to lower case

String.Like(string, pattern) : Boolean

call String.Like("123456", "12_45") into Result; // true
call String.Like("023456", "12_45") into Result; // false
call String.Like("023456", "%45")   into Result; // true
call String.Like("cat house dog", "%house%") into Result; // true
call String.Like("cat HOUSE dog", "%house%") into Result; // true
call String.Like("123456", null) into Result; // false

Compares two strings. % will match any number of characters, _ will match any single character. Strings are compared case-insensitive. Note: if the pattern is null or empty, the method will return false  

String.Replace(string, searchString, replacementString) : Text

call String.Replace("123456", "34", "##") into Result; // "12##56"
call String.Replace("abABab", "b", "#") into Result; // "a#ABa#"
call String.Replace("12345", null, "#") into Result; // 12345
call String.Replace("123456", "34", null) into Result; // 1256

Replaces all occurrences of searchString with replacementString. Note: - If searchString is null, the original string is returned - If replacementString is null, the searchString is removed from the original string

String.RegexLike(string, pattern) : Boolean

String.RegexLike(string, pattern, options) : Boolean

call String.RegexLike("abcde", "ab[ch]de") into Result; // true
call String.RegexLike("abhde", "ab[ch]de") into Result; // true
call String.RegexLike("abab", "ABAB") into Result; // false
call String.RegexLike("abab", null) into Result; // false
call String.RegexLike("abab", "ABAB", "i") into Result; // true

Compares two strings using regular expressions. Note: if the pattern is null, the result is false.

String.RegexReplace(string, pattern, replacementString) : Text

String.RegexReplace(string, pattern, replacementString, options) : Text

call String.RegexReplace("abcac", "c", "d",) into Result; // "abdad"
call String.RegexReplace("abcac", null, "d",) into Result; // "abcac"
call String.RegexReplace("abCac", "c", "d",) into Result; // "abCad"
call String.RegexReplace("abCac", "c", "d", "i") into Result; // "abdad"

Replaces all occurrences of pattern with replacementString. Note:

String.RegexSubString(string, pattern) : Text

String.RegexSubString(string, pattern, position, occurence) : Text

String.RegexSubString(string, pattern, position, occurence, options) : Text

call String.RegexSubString("a,b,c", "[^,]+") into Result; // "a"
call String.RegexSubString("a,b,c", null) into Result; // null
call String.RegexSubString("a,b,c", "[^,]+", 0, 1) into Result; // "b"
call String.RegexSubString("a,b,c", "[^,]+", 2, 0) into Result; // "b"

Finds a substring of string that matches the regex pattern.

Note:

String.RegexCount(string, pattern) : Number

String.RegexCount(string, pattern, position) : Number

String.RegexCount(string, pattern, position, options) : Number

call String.RegexCount("a,b,c", "[^,]+") into Result; // 3
call String.RegexCount("a,b,c", "[^,]+", 2) into Result; // 2

Count the occurrences of the regex pattern in the string.

Regular Expression Options

Note:

String.Tokenize(string, delimiter) : List\

call String.Tokenize("TASK_SEQ=20267^&TASK_SEQ=20268^", "&") into Result; 
// List<Text> { "TASK_SEQ=20267^", "TASK_SEQ=20268^" }
call String.Tokenize("foo=bar^;test=value^", ";") into Result; 
// List<Text> { "foo=bar^", "test=value^" }
call String.Tokenize("test1^test2^^test3", "^") into Result; 
// List<Text> { "test1", "test2", "test3" }

Note:

Convert.ToNumber(value) : Number

call Convert.ToNumber("505") into Result; // 505
call Convert.ToNumber("505.7") into Result; // 505.7

Converts a value to a number Note: if an incorrect value is passed, the default value of null will be returned

Convert.ToInteger(value) : Number

call Convert.ToInteger("505") into Result; // 505
call Convert.ToInteger("505.7") into Result; // 505
call Convert.ToInteger("2015-09-15T07:00:00") into Result; // null
call Convert.ToInteger(true) into Result; // 1
call Convert.ToInteger(false) into Result; // 0
Converts a value to an integer

Note: if an incorrect string value is passed, null will be returned  

Convert.ToBoolean(value) : Boolean

call Convert.ToBoolean("true") into Result; // true
call Convert.ToBoolean("True") into Result; // true
call Convert.ToBoolean("TRUE") into Result; // true
call Convert.ToBoolean("false") into Result; // false
call Convert.ToBoolean(0) into Result; // false
call Convert.ToBoolean(1) into Result; // true
call Convert.ToBoolean("HelloWorld") into Result; // null

Converts a value to a boolean. Note: if an incorrect value is passed, the default value of null will be returned

Convert.ToTimestamp(value) : Timestamp

call Convert.ToTimestamp("2018-06-28T13:01:46") into Result; 
    // Result = 2018/06/28 13:01:46.000000
call Convert.ToTimestamp("2018-06-28T13:01:46.0000000") into Result; 
    // Result = 2018/06/28 13:01:46.000000
call Convert.ToTimestamp("2018/06/28 13:01:46") into Result; 
    // null

Converts a value to a timestamp Note: if an incorrect Timestamp format is passed to this method, the result will be null

Convert.ToString(value) : Text

call Convert.ToString(NumberVariable) into Result; // Result "505.7"
call Convert.ToString(IntegerVariable) into Result; // Result "505"
call Convert.ToString(BooleanVariable) into Result; // Result "True"
call Convert.ToString(TimestampVariable) into Result; // Result "2018-06-28T13:01:46.0000000"

Converts a value to a string

Attachment

Attachment.CreateAndConnectDoc(string LuName, string KeyRef)

Attachment.CreateAndConnectDoc(string LuName, string KeyRef, string Title)

// variable Keys Structure(FndDocumentKeys);
call Attachment.CreateAndConnectDoc("WorkOrder", "WO_NO=3323^", "My Document Title")
    into Keys; 

Creates a new document with Title and connects it to the specified record by LuName and KeyRef. This call will return the keys of the document (DocClass, DocNo, DocSheet and DocRev) which can later be used in the upload statement of a command.

Attachment.GetDocFileExtensions()

// variable FileExts Text
call Attachment.GetDocFileExtensions() into FileExts;

Returns a comma separated list of file extensions that can be used when attaching files to a document created by CreateAndConnectDoc.

Attachment.CreateAndConnectMedia(string LuName, string KeyRef)

Attachment.CreateAndConnectMedia(string LuName, string KeyRef, string Name)

// variable Keys Structure(FndMediaKeys);
call Attachment.CreateAndConnectMedia("WorkOrder", "WO_NO=3323^", "My Media Name")
    into Keys; 

Creates a new media item with Name and connects it to the specified record by LuName and KeyRef. This call will return the keys of the media item (ItemId) which can later be used in the upload statement of a command.

Attachment.GetMediaFileExtensions()

// variable FileExts Text
call Attachment.GetMediaFileExtensions() into FileExts;

Returns a comma separated list of file extensions that can be used when attaching files to a media item created by CreateAndConnectMedia.

Where Expression Methods

A limited subset of the system calls that can be used in procedures can also be used in where expressions. E.g.: using the current timestamp within a count query or an offline filter:

offlinefilter = [DateTime.Timestamp() < ExpiresAt];
count Reports where [DateTime.Timestamp() < ExpiresAt] into ReportCount;

The following calls can be made in where expressions:

DateTime.Timestamp(): Timestamp
DateTime.Date() : Date
DateTime.Date(Timestamp ts) : Date
DateTime.Time(Timestamp ts) : Time
DateTime.AddYears(Timestamp ts, Integer years) : Timestamp
DateTime.AddMonths(Timestamp ts, Integer months) : Timestamp
DateTime.AddDays(Timestamp ts, Number days) : Timestamp
DateTime.AddHours(Timestamp ts, Number hours) : Timestamp
DateTime.AddMinutes(Timestamp ts, Number minutes) : Timestamp
DateTime.AddSeconds(Timestamp ts, Integer seconds) : Timestamp
String.Like(string, pattern) : Boolean