Call(function, parameters?)
Calls function with array or dictionary of parameters.
Call Parameters
function : Function
parameters? : []?
Parameters array or dictionary (name -> value).
Call Examples
var ok = Url.Call(['http://test.com', 'request', { q = '1' }]).Url == 'http://test.com/request?q=1';
var ok = Url.Call({ url = 'http://test.com/request', params = { q = '1' } }).Url == 'http://test.com/request?q=1';
DebugBreak(result?)
Pauses script execution and waits for the debugger (if attached).
DebugBreak Parameters
result? : ?
Value to return as a result.
DefaultIfMissing(identifier, defaultValue?)
Returns value of the identifier, or default value if the identifier is missing.
DefaultIfMissing Parameters
identifier : ?
defaultValue? : ?
DefaultIfMissing Examples
var ok = DefaultIfMissing(unknownVar, 5) == 5;
Error(error, details?)
Raises an error.
Error Parameters
error : String
Message string (or error object).
details? : Dict?
Additional error details (if 1st arg is message).
Error Examples
Error('Operation failed');
Error('Operation failed', { Code = 5 });
Eval(code, guard, scope?)
Evaluates user-defined script.
Eval Parameters
code : String
Script code to execute.
guard : Function
func(op, funcOrObj, prop) where op can be ‘func’ or ‘prop’.
scope? : Dict?
Variables available to the script code.
Expression(expression, unwrapIdentifier = true, parseString = false)
Returns AST of the argument expression.
Expression Parameters
expression : ?
unwrapIdentifier : Boolean = true
parseString : Boolean = false
True to parse expression from string.
Expression Examples
var ok = Expression(a == 1).TypeName == 'Equal';
External(name, params?, onOutputLine?) : Dict?
Executes configured external utility.
Returns dict { Code, Output, Error }.
External Parameters
name : String
Configured utility name.
params? : Dict?
Parameters for the utility.
onOutputLine? : Function?
Callback function ((line) => any) on each output line from the utility.
Functions(name?) : []
Returns available functions.
Functions Parameters
name? : ?
String name to return one function, true to get all functions, omit to get all names.
GetFunctionConfig(key) : String?
Returns configuration string value for the key ‘Functions/{funcname}/{key}’.
Works only for script functions from internal resource storage (res:///functions/{funcname}.gs).
Returns null if the configuration key is missing or the value is empty.
GetFunctionConfig Parameters
key : String
GetFunctionConfig Examples
var password = GetFunctionConfig('Password');
GetType(value, full?) : String?
Returns value type.
GetType Parameters
value : ?
full? : ?
True to get ArgumentType descriptor, ‘schema’ to try getting full type schema first.
GetType Examples
var ok = GetType('string') == 'String';
var ok = GetType('string', true).ValueType == 'String';
var schema = GetType($.MySolution, 'schema');
LazyCall(function, parameters?, once = false)
Calls function with array or dictionary of parameters on demand.
LazyCall Parameters
function : Function
parameters? : []?
parameters array or dictionary name -> value
once : Boolean = false
LazyCall Examples
var ok = Url.LazyCall(['http://test.com', 'request', { q = '1' }]).Url == 'http://test.com/request?q=1';
var ok = Url.LazyCall({ url = 'http://test.com/request', params = { q = '1' } }).Url == 'http://test.com/request?q=1';
Log(value, prefix?)
Dumps value to debug log (string value is logged as is).
Log Parameters
value : ?
prefix? : ?
Prefix is added before the value.
LogError(error, params?) : Error?
Adds an error to the error log.
LogError Parameters
error : ?
Error object or message.
params? : Dict?
Additional parameters to add to the error log.
LogError Examples
Safe(Error('Some error'), e => (LogError(e), false));
LogError('Some error', { Details = 'More info' });
NotFoundError(message, targetType?, targetName?)
Raises a not-found error (404 code if called from Web API).
NotFoundError Parameters
message : String
targetType? : String?
targetName? : String?
NotFoundError Examples
NotFoundError('Item was not found');
NotFoundError('Item was not found', 'Item', 'Item Name');
PermissionError(message, operation?, targetType?, targetName?)
Raises a permission error (403 code if called from Web API).
PermissionError Parameters
message : String
operation? : String?
targetType? : String?
targetName? : String?
PermissionError Examples
PermissionError('Item is not accessible');
PermissionError('Item is not accessible', 'Read', 'Item', 'Item Name');
Resolve(value, deep = false)
Resolves parameter to the final value (evaluates lazy value).
Resolve Parameters
value : ?
deep : Boolean = false
True to resolve array/dict items.
Safe(expr1, expr2OrCatch?, …)
Returns the first argument that evaluates without error, or null otherwise.
Safe Parameters
expr1 : ?
expr2OrCatch? : ?
If function is provided, then it is called with the error as the argument: catch(error), and the result of the function is used as the result of the Safe function.
…? : ?
Safe Examples
var ok = Safe(Error('Operation failed'), 10) == 10;
var ok = Safe(Error('Operation failed'), e => (LogError(e), 10)) == 10;
SetVariable(name, value)
Sets a script global variable.
SetVariable Parameters
name : String
value : ?
SetVariable Examples
SetVariable('a', 10);
var ok = a == 10;
Sleep(ms = 1000)
Delays task execution for a certain amount of milliseconds.
Sleep Parameters
ms : Integer = 1000
Number of milliseconds to wait.
Sleep Examples
Sleep(1000);
Switch(testValue, case1, result1, …, defaultResult?)
Returns a result that corresponds to a case that matches testValue.
If testValue does not match any case, then defaultResult is returned (or error is raised if no default result).
Switch Parameters
testValue : ?
case1 : ?
result1 : ?
…? : ?
defaultResult? : ?
Switch Examples
a = 10; var ok = Switch(a, 1, 'NO', 10, 'YES') == 'YES';
a = 10; var ok = Switch(a, 1, 'NO', 2, 'YES', 'DEF') == 'DEF';
ToExpression(value)
Serializes value to expression.
ToExpression Parameters
value : ?
ToExpression Examples
var ok = ToExpression([1, 2]) == '[1, 2]';
Types(name?) : []
Returns available types.
Types Parameters
name? : String?
Non-null value to return one type by name, otherwise get all types.