Server-Side Javascript ES6 API Reference
RMPData
Fundamental Methods about the current Execution Scope
Get Current User
Get the current application user information
Syntax : RMPData.getCurrentUser();
Parameters : None
Returns : Details of the current Application User
Type : Map
Data Structure :
{"name": "{String}",
"status": "{String}",
"login": "{String}",
"profile": "{String}",
"lang": "{String}",
"client_lang": "{String}",
"restrictions": [ {array} ],
"i18n": "{String}",
"alias": ["{String}", ...], -- optional
"delegators": [ {array} ] -- optional
"extended": { map }, -- optional
"preferences": { map } -- optional
}
Call Example :
<@script env="js">
var u = RMPData.getCurrentUser();
</@script>
Get Execution Mode
Get the execution mode of the application
Syntax : RMPData.getExecutionMode();
Parameters : None
Returns : Application Execution Mode
Type : String
Call Example :
<@script env="js">
var m =RMPData.getExecutionMode();
</@script>
Get All Context Variables
Get all variables from the context of a process request.
Syntax : RMPData.getAllContextVariables()
Parameters : None
Returns : Details of the current Application User
Type : Map
Call Example :
<@script env="js">
RMPData.setContextVariable("var2","20");
var v = RMPData.getAllContextVariables();
RMPData.setOutput(v);
</@script>
Get App Instance ID
Get the Wi instance ID mapped with the current process. This function works only when we link the web interface to get the App instance ID.
Syntax : RMPData.getAppInstanceId();
Parameters : None
Returns : The identifier of the app instance is mapped with the current request.
Type : String
Call Example :
<@script env="js">
var id = RMPData.getAppInstanceId();
</@script>
Get Context Variable
Get variables with a key from the context of a process request.
Syntax : RMPData.getContextVariable(key)
Parameters :
Name | Type | Description |
---|---|---|
Key | String | key of the Object |
Returns : Return the JSON object as a string representing the context variable for the given key.
Type : String
Call Example :
<@script env="js">
RMPData.setContextVariable("var2","20");
var v = RMPData.getContextVariables("va2");
RMPData.setOutput(v);
</@script>
Get Project ID
Get the project Id of the current request.
Syntax : RMPData.getProjectId();
Parameters : None
Returns : Identifier of the project.
Type : Long
Call Example :
<@script env="js">
var id = RMPData.getProjectId();
</@script>
Log (message)
Sends a custom message to RunMyLog
Syntax : RMPData.log("msg");
Parameters :
Name | Type | Description |
---|---|---|
msg | String | Text sent to the Log |
Returns : The result of the log operation
Type : Boolean
Call Example :
<@script env="js">
RMPData.log("Executed Successfully");
</@script>
Log with (String, String)
Log a message.
Logs in the P_message variable of the request and in the Mongo data of the customer. In TEST mode all the levels are logged but in LIVE mode, only SEVERE level is logged. This rule is skipped if the attributes P_log is present in the resource, in this case, the given P_log will be the reference.
Syntax : RMPData.log(String, String);
Parameters :
Name | Type | Description |
---|---|---|
level | String | Level of the log (SEVERE, WARNING, INFO, CONFIG, FINE, FINER, FINEST). |
message | String | Message to be logged. The size of the message is limited to 3Kbytes: any bigger message is truncated, and terminated by "(...)" |
Returns : Logged message
Type : String
Call Example :
<@script env="js">
RMPData.log("medium","value");
</@script>
Raise Event
Syntax: RMPData.raiseEvent(customKey, customMessage, isFailure, customData)
Parameters:
Name | Type | Description |
---|---|---|
customKey | String | Name of the custom key |
customMessage | String | Some custom message that you'd like to include |
isFailure | Boolean | Classifies whether the event represents a failure or is informational |
customData | Map | Custom data in JSON format |
Note:
- If you want to create an event subscription on the custom event, you will have to enter the customKey as the eventType in the Event Management UI. Also, note that the customKey must only contain characters and digits. Custom events will always show up in the logs regardless of whether you have defined a subscription for forwarding the event to a CAPI.
Returns:
- Boolean representing whether the call was successful
Call Example :
<@script env="js">
var data = {'key':'value'};
var x = RMPData.raiseEvent('NameOfTheTestEvent', 'SomeCustomMessage', false, data);
...
</@script>
Set Output
Returns the value of the variable passed
Syntax : RMPData.setOutput(value);
Parameters :
Name | Type | Description |
---|---|---|
value | Any of Boolean, Integer, String, Map, Array of maps | The return value to the process (to be converted to text format) |
Returns : The output of the value passed
Type : Void
Call Example :
<@script env="js">
var moderesult=RMPData.getExecutionMode();
RMPData.setOutput(moderesult);
</@script>
Set Context Variable
Add a variable with a key to the context of a process request.
Syntax : RMPData.setContextVariable(key, value)
Parameters :
Name | Type | Description |
---|---|---|
key | String | Key to Object |
value | Object | Object to be set to the context. |
Call Example :
<@script env="js">
RMPData.setContextVariable("var2","20");
</@script>
Please give details of the problem