×

Please give details of the problem

Skip to content
Table of Contents

RunMyScript (RMS)

Introducing RunMyScript (RMS), a new scripting engine designed to elevate the functionality and capabilities of our application, allows you to execute custom JavaScript functions seamlessly alongside Freemarker functions.

This section will walk you through the essential steps and concepts of using RMS, and help you streamline your workflow, whether you're looking to automate tasks, extend functionality, or solve complex problems.

Workflow Steps

Basic Script Setup

The new engine can be triggered when specifying a script like this (e.g. as input/output parameters of a process):

1
2
3
<@script env="js">
... javascript code here ...
< /@script >

Please note that compared to the existing engine, you have to specify <@script env="js"> rather than <@script env="javascript">

Besides the standard Javascript language, there are a number of RMP Objects which provide access to custom functions. Namely: - RMPApplication - application-centric functions - RMPCollection - access to customer MongoDB collections - RMPData - response data handling - RMPFile - access to files (S3 bucket) - RMPProject - - RMPRequest - process-request centric functions (also lock/unlock) - RMPUser - user-centric functions - RMPUtilities - some useful helper functions

The basic usage is like

1
2
3
<@script env="js">
var someResponse = RMPCollection.createCollection("some collection name");
< /@script >

Broadly, these custom functions resemble those from the Freemarker environment.

Response Handling

There are 2 ways for returning data to the caller (e.g. a process).

The response object has to be an Object that can be translated into a String. Namely: - String - Number - Boolean - JSONObject - JSONArray

Option 1:

You can specify the response explicitly via the custom function below.

1
2
3
<@script env="js">
RMPData.setOutput(someResponseObject);
< /@script >

Option 2:

You can implement a function that returns the value.

1
2
3
<@script env="js">
(function(t) {  return someResponseObject; })
< /@script >

Saving Data into the Process Context

1
2
3
4
5
<@script env="js">
...
RMPData.setContextVariable(someKey, someValue);
...
< /@script >

JS Engine vs Freemarker Equivalence

Freemarker:

1
2
<#assign result = append_file("73f01850-1a85-11ec-8413-8c859067f180","coucou")>
${result}

So you use the <#assign x=y> for assigning a value to a variable.

${x} is used to return the variable value to the workflow / app.

You may also spot the following variation:

1
2
3
4
<#assign result>
append_file("73f01850-1a85-11ec-8413-8c859067f180","coucou")
<!--#assign-->
${result}

JS (Option 1 in chapter Response Handling):

1
2
3
4
<@script env="js">
var result = RMPFile.append("73f01850-1a85-11ec-8413-8c859067f180","coucou");
RMPData.setOutput(result);
< /@script >

var x = y; is a standard JS value assignment.

User RMPData.setOutput(x); for returning the variable value to the workflow / app.

Supported Custom Functions

RMPApplication

Methods for Application

1. Attach File

Find the last occurrence of a string in a file.

Syntax : RMPApplication.attachFile(fileIds, widgetId);

Parameters :

Name Type Argument Description
fileID String / Array The variable of an uploaded file widget, containing one file identifier or a list of file identifiers
file widgetID String optional Identifier of the uploaded file widget to which the file(s) should be attached. Necessary if several uploaded file widgets are present in the application.

Returns : Descriptors of the attached files.

Type : Array

Example :

1
2
3
4
5
<@script env="js">
var fileIds = ["fd58e98b-447e-42f8-8a78-24b55d928f3e"];
var res =  RMPApplication.attachFile(fileIds,"uploadFile_1");
RMPData.setOutput(res);
< /@script >

2. Detach File

Detach a file or a list of files from an application.

Syntax : RMPApplication.detachFile(fileIds,instanceId);

Parameters :

Name Type Description
fileID String / Array One file identifier or a list of file identifiers in a JSONArray format or the variable of an uploaded file widget
instanceId String Application instance from which the file(s) shall be detached.

Returns : Descriptors of the detached files.

Type : Array

Example :

1
2
3
4
5
6
<@script env="js">
var fileIds = ["fd58e98b-447e-42f8-8a78-24b55d928f3e"];
var instId = RMPData.getAppInstanceId();
var res =  RMPApplication.detachFile(fileIds,instId);
RMPData.setOutput(res);
< /@script >

3. Get History

Get the history of modifications of application instances during a process, just as the history widget would do it.

Syntax : RMPApplication.getHistory();

Parameters : None

Returns : Array of history metadata.

Type : Array

Example :

1
2
3
<@script env="js">
RMPApplication.getHistory();
< /@script >

4. Get Instance Info

Get the metadata describing an application instance.

Syntax : RMPApplication.getInstanceInfo(instanceId);

Parameters :

Name Type Description
instanceId String Application instance.

Returns : Application instance description.

Type : Application metadata

Example :

1
2
3
<@script env="js">
RMPApplication.getInstanceInfo("2518ba82-b617-4e5b-8673-6ba414b19203");
< /@script >

5. GetI18n

Internationalization method. Get the translation of a key in a given language. With this method, you can enforce the language type. It applies to all process activities, not only to email activities.

Syntax : RMPApplication.getI18n(key, defaultValue, language)

Parameters :

Name Type Argument Description
key String - -
defaultValue String - Default value if key is not found in language
language String Optional Language code (two letters)

Returns : Target translation or defaultValue if nothing is found.

Type : String

Example :

1
2
3
4
<@script env="js">
var res =  RMPApplication.getI18n("Text","defaultVal");
RMPData.setOutput(res);
< /@script >

6. List Attached Files

List the files attached to an application.

Syntax : RMPApplication.listAttachedFiles(instanceId);

Parameters :

Name Type Description
instanceId String Application instance.

Returns : Descriptors of the attached files.

Type : Array

Example :

1
2
3
4
5
<@script env="js">
var instanceId = "4ab793b0-6157-49b7-b95f-3112360a8f9a";
var res =  RMPApplication.listAttachedFiles(instanceId );
RMPData.setOutput(res);
< /@script >


RMPCollections

Methods for Collections

7. Aggregate

Run an aggregation query over a collection

Syntax : RMPCollection.aggregate(collectionName, pipelines);

Parameters :

Name Type Description
collectionName String Name of the collection
pipelines List (Map) An aggregation requires at least one pipeline

Returns : The result of the aggregate operation

Type : List (Map)

Example :

1
2
3
4
5
<@script env="js">
var aggr = [ {'$match': {'brand_id':'bogdan_group'} }, { $group : { _id : '$name', totaldocs : { $sum : 1 } } } ];
var a = RMPCollection.aggregate('car_rms', aggr );
RMPData.setOutput(a);
< /@script >

8. Count Documents

Count documents verifying a condition in a collection

Syntax : RMPCollection.countDocuments(collectionName, query);

Parameters :

Name Type Description
collectionName String Name of the collection
query Map Query to filter objects to be retrieved

Returns : The number of documents matching the query

Type : Long

Example :

1
2
3
4
5
<@script env="js">
var query = {};
var f = RMPCollection.countDocuments('car_rms', query);
RMPData.setOutput(f);
< /@script >

9. Create Collection

Creates a new collection

Syntax : RMPCollection.createCollection(collectionName, isPublic, isReadonly);

Parameters :

Name Type Description
collectionName String Name of the collection
isPublic Boolean If true the collection can be accessed publicly, without checking rights
isReadonly Boolean If true the collection can only be modified by an administrator of the customer account

Returns : Collection successfully created or not

Type : Boolean

Example :

1
2
3
4
<@script env="js">
var f = RMPCollection.createCollection('col_rms_v3', false, false);
RMPData.setOutput(f);
< /@script >

10. Create Index

Creates indexes on collection

Syntax : RMPCollection.createIndex(collectionName, indexName, indexArray);

Parameters :

Name Type Description
collectionName String Name of the collection
indexName String Name of the Index
indexArray List (String) Index Array

Returns : The result of the create operation (true or false)

Type : Boolean

Example :

1
2
3
4
5
<@script env="js">
var idx = ['brand_id'];
var f = RMPCollection.createIndex('rms_car', 'rms_car_idx', idx);
RMPData.setOutput(f);
< /@script >

11. Delete Index

Remove an index on a collection

Syntax : RMPCollection.dropIndex(collectionName, indexName);

Parameters :

Name Type Description
collectionName String Name of the collection
indexName String Name of the Index

Returns : The result of the delete operation (true or false)

Type : Boolean

Example :

1
2
3
4
<@script env="js">
var f = RMPCollection.dropIndex('rms_car', 'rms_car_idx');
RMPData.setOutput(f);
< /@script >

12. Import CSV

Import objects in a collection from a CSV file

Syntax : RMPCollection.importCSV(fileId, collectionName, options);

Parameters :

Name Type Description
fileId String Reference of an uploaded file
collectionName String Name of the collection
options Object Options to be used during the call, all values are optional
Name Type Argument Default Description
separator String , Separator between two values (for example ; or ,)
delimiter String " Delimiter used to allow values containing the separator character (for example " or '), to include a delimiter in a value, use two delimiters ("" for example)
empty String "" Value to be used to represent an empty value (two separators in a row)
charset String UTF-8 Character set to be used to read the file content.
parse_numbers Array Array of names or indices (zero based) of columns containing numerical values that should be stored as numbers (double). Examples : ["age",3] is asking the loader to parse column with header "age" and the fourth column
parse_longs Array Array of names or indices (zero based) of columns containing long values that should be stored as longs. Examples : ["age",3] is asking the loader to parse column with header "age" and the fourth column.
trim boolean true to trim values before inserting them in the collection. The trimmed value will be the parsed value, with any leading and trailing whitespace removed. Trimming also occurs before decoding numerical values. false to keep values unchanged.

Throws : Uploaded file X doesn't exist.

Returns : The number of imported objects.

Type : Integer

Example :

1
2
3
4
5
<@script env="js">
var options = {};
var noOfRecords = RMPCollection.importCSV("30ad9a42-8a4e-48b3-b857-660979eb77dd", "csks", options);
RMPData.setOutput(noOfRecords);
< /@script >

13. Import JSON

Import objects in a collection from a JSON file.

Syntax : RMPCollection.importJSON(fileId, collectionName, options);

Parameters :

Name Type Description
fileId String Reference of an uploaded file
collectionName String Name of the collection
options Object Options to be used during the call, all values are optional
Name Type Argument Default Description
separator String , Separator between two values (for example ; or ,)
delimiter String " Delimiter used to allow values containing the separator character (for example " or '), to include a delimiter in a value, use two delimiters ("" for example)
empty String "" Value to be used to represent an empty value (two separators in a row)
charset String UTF-8 Character set to be used to read the file content.
parse_numbers Array Array of names or indices (zero based) of columns containing numerical values that should be stored as numbers (double). Examples : ["age",3] is asking the loader to parse column with header "age" and the fourth column
parse_longs Array Array of names or indices (zero based) of columns containing long values that should be stored as longs. Examples : ["age",3] is asking the loader to parse column with header "age" and the fourth column.
trim boolean true to trim values before inserting them in the collection. The trimmed value will be the parsed value, with any leading and trailing whitespace removed. Trimming also occurs before decoding numerical values. false to keep values unchanged.

Throws : Uploaded file X doesn't exist.

Returns : The number of imported objects.

Type : Integer

Example :

1
2
3
4
5
<@script env="js">
var options = {};
var noOfRecords = RMPCollection.importJSON("fd58e98b-447e-42f8-8a78-24b55d928f3e",   "property", options);
RMPData.setOutput(noOfRecords);
< /@script >

14. List

Retrieve objects from a collection

Syntax : RMPCollection.find(collectionName, query);

Parameters :

Name Type Description
collectionName String Name of the collection
query Map Query to filter objects to be retrieved.

Returns : List of objects

Type : List (Map)

Example :

1
2
3
4
5
<@script env="js">
var query = {};
var f = RMPCollection.find('car_rms', query);
RMPData.setOutput(f);
< /@script >

15. List Index

List of all indexes on a collection

Syntax : RMPCollection.listIndexes(collectionName);

Parameters :

Name Type Description
collectionName String Name of the collection

Returns : List of indexes

Type : List (Map)

Example :

1
2
3
4
<@script env="js">
var l = RMPCollection.listIndexes('rms_car');
RMPData.setOutput(l);
< /@script >

16. Remove Collection

Remove a collection

Syntax : RMPCollection.drop(collectionName);

Parameters :

Name Type Description
collectionName String Name of a collection

Returns : Collection successfully removed or not

Type : Boolean

Example :

1
2
3
4
<@script env="js">
var f = RMPCollection.drop('col_rms_v1_new');
RMPData.setOutput(f);
< /@script >

17. Remove Field

Remove a field from documents that matches with the given query

Syntax : RMPCollection.deleteField(collectionName, query, fieldName);

Parameters :

Name Type Description
collectionName String Name of a collection
query Map Query to filter objects to be retrieved
fieldName String Name of the field

Returns : Number of updated objects

Type : Integer

Example :

1
2
3
4
5
<@script env="js">
var query = {"name":"delete_me!"};
var num = RMPCollection.deleteField('car_rms', query, 'engine');
RMPData.setOutput(num);
< /@script >

18. Remove Objects

Remove fields from documents that matches with the given query

Syntax : RMPCollection.deleteMany(collectionName, query);

Parameters :

Name Type Description
collectionName String Name of a collection
query Map Query to filter objects to be retrieved

Returns : Number of removed objects

Type : Integer

Example :

1
2
3
4
5
<@script env="js">
var query = {'brand_id':'b3'};
var num = RMPCollection.deleteMany('car_rms', query);
RMPData.setOutput(num);
< /@script >

19. Rename Collection

Rename a collection

Syntax : RMPCollection.renameCollection(oldCollectionName, newCollectionName);

Parameters :

Name Type Description
oldcollectionName String Current name of the collection
newcollectionName String New name of the collection

Returns : Renaming successful or not.

1
`false` -  if `oldCollectionName` doesn't designate an existing collection.

Type : Boolean

Example :

1
2
3
4
<@script env="js">
var f = RMPCollection.renameCollection('col_rms_v1', 'col_rms_v1_new');
RMPData.setOutput(f);
< /@script >

20. Save Object

Insert object in a collection

Syntax : RMPCollection.insertOne(collectionName, data);

Parameters :

Name Type Description
collectionName String Name of the collection
data Map Data to store in a collection

Returns : The saved data

Type : Map

Example :

1
2
3
4
5
<@script env="js">
var payload = {"engine":"e1","brand_label":"Brand-1","name":"Name-1","brand_id":"b1"};
var f = RMPCollection.insertOne('car_rms', payload);
RMPData.setOutput(f);
< /@script >

21. Save Objects

Insert many objects in a collection

Syntax : RMPCollection.insertMany(collectionName, data);

Parameters :

Name Type Description
collectionName String Name of the collection
data List (Map) Data to store in a collection

Returns : The saved data

Type : List (Map)

Example :

1
2
3
4
5
<@script env="js">
var payload = [{"engine":"e2","brand_label":"Brand-2","name":"Name-2","brand_id":"b2"}, {"engine":"e3","brand_label":"Brand-3","name":"Name-3","brand_id":"b3"}];
var f = RMPCollection.insertMany('car_rms', payload);
RMPData.setOutput(f);
< /@script >

22. Update Field (updateMany)

Update fields on a subset of the documents in a collection

Syntax : RMPCollection.updateField(collectionName, query, data, multipleDocuments);

Parameters :

Name Type Description
collectionName String Name of the collection
query Map Query to filter objects to be retrieved
data Map Data to be updated in a collection
multipleDocuments Boolean True if multiple documents have to be updated

Returns : Number of updated fields

Type : Integer

Example :

1
2
3
4
5
6
<@script env="js">
var query = {"brand_id" : "bogdan_group"};
var upd = {"engine":"engine_3"};
var num = RMPCollection.updateField('car_rms', query, upd, true);
RMPData.setOutput(num);
< /@script >

23. Update Field (updateOne)

Update a field on a subset of the documents in a collection

Syntax : RMPCollection.updateField(collectionName, query, data);

Parameters :

Name Type Description
collectionName String Name of the collection
query Map Query to filter objects to be retrieved
data Map Data to be updated in a collection

Returns : Number of updated fields

Type : Integer

Example :

1
2
3
4
5
6
<@script env="js">
var query = {"brand_id" : "bogdan_group"};
var upd = {"engine":"engine_3"};
var num = RMPCollection.updateField('car_rms', query, upd, false);
RMPData.setOutput(num);
< /@script >

24. Update Objects

Update fields on a subset of the documents in a collection

Syntax : RMPCollection.updateMany(collectionName, data, query);

Parameters :

Name Type Description
collectionName String Name of the collection
data Map Data to be updated in a collection
query Map Query to filter objects to be retrieved

Returns : Number of updated fields

Type : Integer

Example :

1
2
3
4
5
6
<@script env="js">
var query = {'brand_id':'b2'};
var upd = {'$set':{'engine':'e2','brand_label':'Brand-2','name':'Name-2'}}; 
var num = RMPCollection.updateMany('car_rms', upd, query);
RMPData.setOutput(num);
< /@script >


RMPData

Methods for Data

25. Get Current User

Get the current application user information

Syntax : RMPData.getCurrentUser();

Parameters : None

Returns : Details of the current Application User

Type : Map

Example :

1
2
3
<@script env="js">
RMPData.getCurrentUser();
< /@script >

26. Get Execution Mode

Get the execution mode of the application

Syntax : RMPData.getExecutionMode();

Parameters : None

Returns : Application Execution Mode

Type : String

Example :

1
2
3
<@script env="js">
RMPData.getExecutionMode();
< /@script >

27. 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

Example :

1
2
3
4
5
<@script env='js'>
RMPData.setContextVariable("var2","20");
var v = RMPData.getAllContextVariables();
RMPData.setOutput(v);
< /@script >

28. 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

Example :

1
2
3
<@script env="js">  
RMPData.getAppInstanceId();
< /@script >

29. 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

Example :

1
2
3
4
5
<@script env='js'>
RMPData.setContextVariable("var2","20");
var v = RMPData.getContextVariables("va2");
RMPData.setOutput(v);
< /@script >

30. Get Project ID

Get the project Id of the current request.

Syntax : RMPData.getProjectId();

Parameters : None

Returns : Identifier of the project.

Type : Long

Example :

1
2
3
<@script env="js">  
RMPData.getProjectId();
< /@script >

31. 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

Example :

1
2
3
<@script env="js">
RMPData.log("Executed Successfully");
< /@script >

32. 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

Example :

1
2
3
<@script env="js">  
RMPData.log("medium","value");
< /@script >

33. Ping

Check the server connection

Syntax : RMPData.ping();

Parameters : None

Returns : Server response

Type : String

Example :

1
2
3
<@script env="js">
RMPData.ping();
< /@script >

34. Ping JSON

Check the server connection.

Syntax : RMPData.pingJSON(value )

Parameters :

Name Type Description
value Object object to be returned

Returns : Object to be returned first key and value

Type : Object

Example :

1
2
3
4
<@script env="js">
var v = RMPData.pingJSON({"role":"dev"});
RMPData.setOutput(v);
< /@script >

35. Set Output

Returns the value of the variable passed

Syntax : RMPData.setOutput(value);

Parameters :

Name Type Description
value Value Object Enter the Variable whose value will be given as the output

Returns : The output of the value passed

Type : Void

Example :

1
2
3
4
<@script env="js">
var moderesult=RMPData.getExecutionMode();
RMPData.setOutput(moderesult);
< /@script >

36. 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.

Example :

1
2
3
<@script env="js">
  RMPData.setContextVariable("var2","20");
< /@script >


RMPFile

Methods for Files

37. Append File

Append data to an existing file. Works only for uploaded files.

Syntax : RMPFile.append(fileID, content);

Parameters :

Name Type Description
fileID String Identifier of the file to be appended. A new file is created if ‘fileID’ is empty.
content String The data to be added into the file.

Returns : Identifier of the appended file.

Type : String

Example :

1
2
3
<@script env="js">
RMPFile.append("3146acd0-b0e8-11ed-ac99-ea641a55cdec", 'defghi');
< /@script >

38. Create File

Create a new file. Works only for uploaded files

Syntax : RMPFile.create(name, content);

Parameters :

Name Type Description
name String Name of the file
content String The data to be added into the file.

Returns : Identifier of the created file.

Type : String

Example :

1
2
3
4
<@script env="js">
var f = RMPFile.create('test2.txt', 'abcdef');
RMPData.setOutput(f);
< /@script >

39. Delete File

Delete an existing file. Works only for uploaded files.

Syntax : RMPFile.delete(fileID);

Parameters :

Name Type Description
fileID String Identifier of the file to be deleted.

Returns : The result of the delete operation (true, false)

Type : Boolean

Example :

1
2
3
4
<@script env="js">
var f = "54fedbb0-b9ae-11ed-b944-d68b202471ff";
RMPFile.delete(f);
< /@script >

40. File Content

Read the content of a file.

Syntax : RMPFile.getContent(fileID);

Parameters :

Name Type Description
fileID String Identifier of the file.

Returns : The Content of the file

Type : String

Example :

1
2
3
4
5
<@script env="js">
var f = "3146acd0-b0e8-11ed-ac99-ea641a55cdec";
var content = RMPFile.getContent(f);
RMPData.setOutput(content);
< /@script >

41. File Description

Get the metadata describing a file on the platform.

Syntax : getDescription(fileID);

Parameters :

Name Type Description
fileID String Identifier of the file.

Returns : The description of a file.

Type : JSON Object

Example :

1
2
3
4
5
<@script env="js">
var f = "3146acd0-b0e8-11ed-ac99-ea641a55cdec";
var description = RMPFile.getDescription(f);
RMPData.setOutput(description);
< /@script >

42. File Replace

Replace the occurrences of a string in a file and save it. Works only for uploaded files.

Syntax : RMPFile.replaceInFile(fileID, oldString, replacement);

Parameters :

Name Type Description
fileID String Identifier of the file.
oldString String The data to be replaced
replacement String The data to be inserted or replaced with

Returns : File Identifier.

Type : String

Example :

1
2
3
4
<@script env="js">
var f = "3146acd0-b0e8-11ed-ac99-ea641a55cdec";
RMPFile.replaceInFile(f, 'abc', 'efg');
< /@script >

43. File Size

Get the size in KBytes of a file on the platform.

Syntax : RMPFile.getSize(fileID);

Parameters :

Name Type Description
fileID String Identifier of the file.

Returns : Size of the File in KB (KiloBytes) along with File description.

Type : Map

Example :

1
2
3
4
5
<@script env="js">
var f = "3146acd0-b0e8-11ed-ac99-ea641a55cdec";
var fileSize = RMPFile.getSize(f);
RMPData.setOutput(fileSize);
< /@script >

44. Index Of

Find the index of the first occurrence of a string in a file.

Syntax : RMPFile.indexOf(fileId, substring);

Parameters :

Name Type Description
fileID String Identifier of the file to be searched upon.
substring String Text to be matched with the file content

Returns : Index position of the given string.

Type : Integer

Example :

1
2
3
4
5
<@script env="js">
var f = "3146acd0-b0e8-11ed-ac99-ea641a55cdec";
var idx = RMPFile.indexOf(f, 'ab');
RMPData.setOutput(idx);
< /@script >

45. Last Index Of

Find the last occurrence of a string in a file.

Syntax : RMPFile.lastIndexOf(fileId, substring);

Parameters :

Name Type Description
fileID String Identifier of the file to be read.
substring String String to be searched in the file content.

Returns : Index of the first occurrence or -1 if nothing is found.

Type : Integer

Example :

1
2
3
4
5
<@script env="js">
var f = "c0a25fde-63a7-482e-bdcb-49c1959126aa";
var idx = RMPFile.lastIndexOf(f, 'ab');
RMPData.setOutput(idx);
< /@script >

46. Read Excel Spreadsheet

Read cells from an Excel worksheet. Note: Works for XLSX format of Excel files only

Syntax : RMPFile.readExcelSpreadsheet(fileId, sheetName)

Parameters :

Name Type Description
fileID String Identifier of the Excel file uploaded on the platform.
sheetName String Worksheet descriptor listing the cells to be read.

Returns : Index of the first occurrence or -1 if nothing is found.

Type : Integer

Example :

1
2
3
4
5
6
7
8
9
<@script env="js">
var sheet = RMPFile.readExcelSpreadsheet('54cfc512-2307-494c-a5f7-2e262c3e1add', 'Sheet1');
sheet.forEach(function (item) {
item.forEach( function (item) {
console.log(item);
});
});
RMPData.setOutput(sheet);
< /@script >

47. Save

Overwrite an existing file. Works only for uploaded files.

Syntax : RMPFile.save(fileId, content);

Parameters :

Name Type Description
fileID String Identifier of the file to be overridden.
content String New content of the file.

Returns : Identifier of the file

Type : String

Example :

1
2
3
4
5
<@script env="js">
var f = RMPFile.create('text.txt', 'abcdef');
RMPFile.save(f, 'hirsch');
RMPData.setOutput(f);
< /@script >

48. Save Description

Modify the metadata describing a file on the platform.

Syntax : RMPFile.saveDescription(fileId, metadata);

Parameters :

Name Type Description
fileID String ID of the file to be modified.
metadata filedescriptor New metadata of the file.

Returns : New metadata of the file.

Type : Filedescriptor

Example :

1
2
3
4
5
6
<@script env="js">
var f = RMPFile.create('text.txt', 'abcdef');
var payload = {'desc' : 'file desc'};
var description = RMPFile.saveDescription(f, payload);
RMPData.setOutput(description);
< /@script >

49. UNZIP

Unzip a file, and create a new file with the unzipped data. Works only for uploaded files.

Syntax : RMPFile.unzip(fileID);

Parameters :

Name Type Description
fileID String Identifier of the file to be unzipped.

Returns : UNZIP File Identifier.

Type : List (String)

Example :

1
2
3
4
5
<@script env="js">
var fileId = "bd98d36e-fae7-40e6-98b6-9c115305110f";    
var unzipFileId = RMPFile.unzip(fileId);    
RMPData.setOutput(unzipFileId); 
< /@script >

50. ZIP

Zip a file, and create a new file with the zipped data. Works only for uploaded files.

Syntax : RMPFile.zip(name, fileIDs);

Parameters :

Name Type Description
name String Name for the ZIP file to be created
fileIDs List (String) Identifier of the files to be zipped.

Returns : ZIP File Identifier

Type : String

Example :

1
2
3
4
5
<@script env="js">
var fileId = "54fedbb0-b9ae-11ed-b944-d68b202471ff";
var zipFileId = RMPFile.zip('test.zip', [fileId]);
RMPData.setOutput(zipFileId);
< /@script >


RMPProject

Methods for Project

51. Delete Project Vault

Delete a project vault.

Syntax : RMPProject.deleteProjectVault();

Parameters : None

Returns : True if the project vault has been found and deleted, false otherwise.

Type : Boolean

Example :

1
2
3
4
<@script env="js">
var f = RMPProject.deleteProjectVault();
RMPData.setOutput(f);
< /@script >

52. Get Access URL

Update the metadata of a project.

Syntax : RMPProject.getAccessUrl(includeProtocol);

Parameters :

Name Type Description
includeProtocol Boolean Whether or not including the protocol in the URL.

Returns : URL with or without protocol.

Type : String

Example :

1
2
3
4
<@script env="js">
var f = RMPProject.getAccessUrl(true);
RMPData.setOutput(f);
< /@script >

53. Get Custom List

Get the content of a custom list.

Syntax : RMPProject.getCustomList(listId);

Parameters :

Name Type Description
listId String Identifier of a custom list.

Returns : List of JSONArray format

Type : Array

Example :

1
2
3
4
<@script env="js">
var f = RMPProject.getCustomList("b1eeebf5-d26a-4374-bf4c-03d340f17596");
RMPData.setOutput(f);
< /@script >

54. Get OAuth2 Token

Retrieve an OAuth2 service token.

Syntax : RMPProject.getOAuth2Token(service);

Parameters :

Name Type Description
service string Name of the OAuth2 service which token is to be retrieved.

Returns : The OAuth2 token is associated with the specified service. If found this token will contain at least an access_token field. This can be used for example in the token field of an OAuth2 connector configuration: RMPProject.getOAuth2Token("my_service").access_token. An OAuth2 service token value depends on the current request execution mode.

Type : Object

Example :

1
2
3
4
<@script env="js">
var j = RMPProject.getOAuth2Token("google");
RMPData.setOutput(j);
< /@script >

55. Get Project Metadata

Get the metadata of a project.

Syntax : RMPProject.getProjectMetadata(projectId);

Parameters :

Name Type Description
projectId Integer Identifier of the project.

Throws : Project not found

Returns : Project metadata.

Type : Object

Example :

1
2
3
4
<@script env="js">
var f = RMPProject.getProjectMetadata(23324452);
RMPData.setOutput(f);
< /@script >

56. Get Project Vault

Retrieve the project vault associated with the project containing the current request.

Syntax : RMPProject.getProjectVault();

Parameters : None

Returns : The current request project vault. A project vault value depends on the current request execution mode.

Type : Object

Example :

1
2
3
4
<@script env="js">
var f = RMPProject.getProjectVault();
RMPData.setOutput(f);
< /@script >

57. Save Custom List

Update a custom list with new content.

Syntax : RMPRequest.saveCustomList(listID, Map data);

Parameters :

Name Type Description
listID String Identifier of a custom list
listId Array New content of the custom list

Throws : Custom list not found

Returns : New content.

Type : Array

Example :

1
2
3
4
5
<@script env='js'>
var payload = [{"label":"ab","value":"c"},{"label":"cd","value":"d"}]
var v = RMPProject.saveCustomList("b1eeebf5-d26a-4374-bf4c-03d340f17596", payload);
RMPData.setOutput(v);
< /@script >

58. Save Project Metadata

Update the metadata of a project.

Syntax : RMPProject.saveProjectMetadata(name,metaData);

Parameters :

Name Type Description
name String Identifier of the project.
metaData Object Project metadata

Returns : Project name.

Type : String

Example :

1
2
3
4
<@script env="js">
var f = RMPProject.saveProjectMetadata("testProjectMeta",{"name":"test3"});
RMPData.setOutput(f);
< /@script >

59. Save Project Vault

Modify or create a project vault.

Syntax : RMPProject.saveProjectVault(data);

Parameters :

Name Type Description
vault Object An object representing the vault associated with the project containing the current request. This object may contain any fields.

Returns : The updated project vault.

Type : Object

Example :

1
2
3
4
5
<@script env="js">
var payload = {"project":"TEST","value":"Value test"};
var f = RMPProject.saveProjectVault(payload);   
RMPData.setOutput(f);   
< /@script >


RMPRequest

Methods for Requests

60. Add User To Lane

Add a user to the given runtime lane.

Syntax : RMPRequest.addUserToLane(laneId, userId)

Parameters :

Name Type Description
laneId Integer Identifier of the lane
userId Integer Id or login of the user

Returns : Status if adding a user to the lane.

Type : Boolean

Example :

1
2
3
4
<@script env="js">
var j = RMPRequest.addUserToLane(53877772,65914367);
RMPData.setOutput(j);
< /@script >

61. Get Next URL

Return the URL of a manual task. Provides the URL of a manual task that will be generated when reaching the step stepId. This method can be called outside a manual task's input parameters. In a loop, the returned URL will be set for the next iteration.

Syntax : RMPRequest.getNextUrl(stepId, isPublic, appCtx)

Parameters :

Name Type Description
stepId Integer - - The id of the step as defined in the process design
isPublic boolean - - Use a public task template or not
appCtx boolean Optional web If context=mobile, the generated URL will be adapted to the RunMyApp environment

Returns : Task URL

Type : String

Example 1 :

1
2
3
4
<@script env="js">
var f = RMPRequest.getNextUrl(2,false,"mobile");
RMPData.setOutput(f);
< /@script >

Example 2 :

1
2
3
4
<@script env="js">
var f = RMPRequest.getNextUrl(2, false);
RMPData.setOutput(f);
< /@script >

62. Get Request Info

Describe a process request.

Syntax : RMPRequest.getRequestInfo(requestId);

Parameters :

Name Type Argument Description
requestId String Optional Identifier of the process request to describe. By default the descriptor of the current process request is provided.

Throws : Request not found.

Returns : Process request descriptor.

Type : Object

Example :

1
2
3
4
<@script env="js">
var f = RMPRequest.getRequestInfo("fcb7a691-38bd-4b26-b1a7-82cca9d6ecf0");
RMPData.setOutput(f);
< /@script >

63. Get Task URL

Return the URL of the current manual task. When used within a manual task's input parameters, provides the URL of the manual task to be generated.

Syntax : RMPRequest.getTaskUrl(isPublic);

Parameters :

Name Type Description
isPublic Boolean Use a public task template or not

Returns : Task URL.

Type : String

Example :

1
2
3
4
<@script env="js">
var j = RMPRequest.getTaskUrl(true);
RMPData.setOutput(j);
< /@script >

64. Inject Params

Add the result of the last executed task to the context of a process request.

Syntax : RMPRequest.injectParams();

Parameters : None

Returns : Result of the last executed task.

Type : String

Example :

1
2
3
4
<@script env="js">
var f = RMPRequest.injectParams();
RMPData.setOutput(f);
< /@script >

65. Lock

Lock a resource.

Create a global lock on a customer account to avoid concurrency when accessing a shared resource. This waits for the obtention of the lock if a lock with the same name already exists.

Datadocument: The use of the method R_lock and/or R_unlock will add in the internal parameter a JSONArray with the key P_locks

Syntax : RMPRequest.lock(lockName, timeoutInMs)

Parameters :

Name Type Argument Description
lockName String - Name of the lock
timeoutInMs Long Optional Maximum time to wait to get the lock (in milliseconds). If this number is greater than 40 seconds, the method will wait only 40 seconds
expirationInSecs Long Optional Maximum time the lock could be kept if not released programmatically (in seconds). Default: 1 hour.

Throws : Timeout exception if the request doesn't get the lock

Returns : Status of the lock, lock acquired or not

Type : Boolean

Example :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<@script env="js">
var state = "ok";
var f = RMPRequest.lock("test", 10000);
if (f) {
RMPRequest.unlock("test");
} else {
state= "nok";
}
RMPData.setOutput(state);
< /@script >

66. Raise Error

Return the URL of the current manual task. When used within a manual task's input parameters, provides the URL of the manual task to be generated.

Syntax : RMPRequest.raiseError(errorMessage);

Parameters :

Name Type Description
errorMessage string Error message

Throws : An error(ScriptExecutionException) with the given error messageTask URL.

Example :

1
2
3
4
<@script env="js">
var j = RMPRequest.raiseError(true);
RMPData.setOutput(j);
< /@script >

67. Read File Add Lane with (fileIds, laneIds)

Add lanes allowed to READ the file(s).

Syntax : RMPRequest.readFileAddLane(fileIds, laneIds);

Parameters :

Name Type Description
fileIds Array a list of file identifiers.
laneIds Array a list of file identifiers.

Returns : The list of lanes and users with the appropriate right for each file in JSON: ie: {:{"user":{"READ":[user_ids], "WRITE":[user_ids]}, "lane":{"READ":[lane_ids], "WRITE":[lane_ids]}...}.

Type : JSON object

Example :

1
2
3
4
<@script env="js">
var j = RMPRequest.readFileAddLane(["fb090250-b571-4aba-a25a-77a996fe72ee"],[53762810]);
RMPData.setOutput(j);
< /@script >

68. Read File Add Lane with (fileIds)

Add current request lanes allowed to READ the file(s).

Syntax : RMPRequest.readFileAddLane(fileIds);

Parameters :

Name Type Description
fileIds Array a list of file identifiers.

Returns : The list of users and current lane with the appropriate right for each file in JSON: ie: {:{"user":{"READ":[user_ids], "WRITE":[user_ids]}, "lane":{"READ":[lane_ids], "WRITE":[lane_ids]}...}.

Type : JSON object

Example :

1
2
3
4
<@script env="js">
var j = RMPRequest.readFileAddLane(["fb090250-b571-4aba-a25a-77a996fe72ee"]);
RMPData.setOutput(j);
< /@script >

69. Read File Add User with (fileIds, userIds)

Add users allowed to READ the file(s).

Syntax : RMPRequest.readFileAddUser(fileIds, userIds);

Parameters :

Name Type Description
fileIds Array a list of file identifiers.
userIds Array a list of either user identifiers or user logins

Returns : The list of lanes and users with the appropriate right for each file in JSON: ie: {:{"user":{"READ":[user_ids], "WRITE":[user_ids]}, "lane":{"READ":[lane_ids], "WRITE":[lane_ids]}...}.

Type : JSON object

Example :

1
2
3
4
<@script env="js">
var j = RMPRequest.readFileAddUser(["fb090250-b571-4aba-a25a-77a996fe72ee"],[66021605]);
RMPData.setOutput(j);
< /@script >

70. Read File Add User with (fileIds)

Add connected/login user allowed to READ the file(s).

Syntax : RMPRequest.readFileAddUser(fileIds);

Parameters :

Name Type Description
fileIds Array a list of files identifiers.

Returns : The list of lanes and login user with the appropriate right for each file in JSON: ie: {:{"user":{"READ":[user_ids], "WRITE":[user_ids]}, "lane":{"READ":[lane_ids], "WRITE":[lane_ids]}...}.

Type : JSON object

Example :

1
2
3
4
<@script env="js">
var j = RMPRequest.readFileAddUser(["fb090250-b571-4aba-a25a-77a996fe72ee"]);
RMPData.setOutput(j);
< /@script >

71. Read File Remove Lane with (fileIds, laneIds)

Remove lanes allowed to READ the file(s).

Syntax : RMPRequest.readFileRemoveLane(fileIds, laneIds);

Parameters :

Name Type Description
fileIds Array a list of files identifiers.
laneIds Array a list of lane identifiers.

Returns : The list of lanes and users with the appropriate right for each file in JSON: ie: {:{"user":{"READ":[user_ids], "WRITE":[user_ids]}, "lane":{"READ":[lane_ids], "WRITE":[lane_ids]}...}.

Example :

1
2
3
4
<@script env="js">
var j = RMPRequest.readFileRemoveLane(["03acf9f2-609f-4cb4-bcbe-17e4005e1fea"],[53818190]);
RMPData.setOutput(j);
< /@script >

72. Read File Remove Lane with (fileIds)

Remove the current lane(lane of the request) allowed to READ the file(s).

Syntax : RMPRequest.readFileRemoveLane(fileIds);

Parameters :

Name Type Description
fileIds Array a list of files identifiers.

Returns : The list of users and lane of the request with the appropriate right for each file in JSON: ie: {:{"user":{"READ":[user_ids], "WRITE":[user_ids]}, "lane":{"READ":[lane_ids], "WRITE":[lane_ids]}...}

Example :

1
2
3
4
<@script env="js">
var j = RMPRequest.readFileRemoveLane(["03acf9f2-609f-4cb4-bcbe-17e4005e1fea"]);
RMPData.setOutput(j);
< /@script >

73. Read File Remove User with (fileIds)

Remove connected/login user allowed to READ the file(s).

Syntax : RMPRequest.readFileRemoveUser(fileIds);

Parameters :

Name Type Description
fileIds Array a list of files identifiers.

Returns : The list of lanes and login users with the appropriate right for each file in JSON: ie: {:{"user":{"READ":[user_ids], "WRITE":[user_ids]}, "lane":{"READ":[lane_ids], "WRITE":[lane_ids]}...}

Type : JSON object

Example :

1
2
3
4
<@script env="js">
var j = RMPRequest.readFileRemoveUser(["fb090250-b571-4aba-a25a-77a996fe72ee"]);
RMPData.setOutput(j);
< /@script >

74. Read File Remove User with (fileIds, userIds)

Remove users allowed to READ the file(s).

Syntax : RMPRequest.readFileRemoveUser(fileIds, userIds);

Parameters :

Name Type Description
fileIds Array a list of files identifiers.
laneIds Array a list of either user identifiers or user logins

Returns : The list of lanes and users with the appropriate right for each file in JSON: ie: {:{"user":{"READ":[user_ids], "WRITE":[user_ids]}, "lane":{"READ":[lane_ids], "WRITE":[lane_ids]}...}.

Type : JSON object

Example :

1
2
3
4
<@script env="js">
var j = RMPRequest.readFileRemoveUser(["fb090250-b571-4aba-a25a-77a996fe72ee"],[66021605]);
RMPData.setOutput(j);
< /@script >

75. Remove User From Lane

Remove a user from the given runtime lane.

Syntax : RMPRequest.removeUserFromLane(laneId, userId);

Parameters :

Name Type Description
laneId Integer Identifier of the lane.
userId Integer Id or login of the user

Returns : status if adding a user to the lane.

Type : Boolean

Example :

1
2
3
4
<@script env="js">  
var f = RMPRequest.removeUserFromLane(53877772,65914367);
RMPData.setOutput(f);
< /@script >

76. Set Request Status

Set the status of the current request to the status code.

Syntax : RMPRequest.setRequestStatus(statusCode);

Parameters :

Name Type Description
statusCode integer 102/201/301/302/400/401

Returns : True if status updates else false

Type : Boolean

Example :

1
2
3
4
<@script env="js">
var j = RMPRequest.setRequestStatus(200);
RMPData.setOutput(j);
< /@script >

77. Unlock

Release a lock.

Release a lock acquired with RMPRequest.unlock().

Datadocument: The use of the method lock and/or unlock will add in the internal parameter a JSONArray with the key P_locks

Syntax : RMPRequest.unlock(lockName)

Returns : None

Example :

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<@script env="js">
var state = "ok";
var f = RMPRequest.lock("test", 10000);
if (f) {
RMPRequest.unlock("test");
} else {
state= "nok";
}
RMPData.setOutput(state);
< /@script >

78. Update File Add Lane with (fileIds)

Add current lane(lane of the request) allowed to WRITE/DELETE the file(s).

Syntax : RMPRequest.updateFileAddLane(fileIds);

Parameters :

Name Type Description
fileIds Array a list of files identifiers.

Returns : The list of users and lane of the current request with the appropriate right for each file in JSON: ie: {:{"user":{"READ":[user_ids], "WRITE":[user_ids]}, "lane":{"READ":[lane_ids], "WRITE":[lane_ids]}...}.

Type : JSON object

Example :

1
2
3
<@script env="js">
var j = RMPRequest.updateFileAddLane(["fb090250-b571-4aba-a25a-77a996fe72ee"]); RMPData.setOutput(j);
< /@script >

79. Update File Add Lane with (fileIds, laneIds)

Add lanes allowed to WRITE/DELETE the file(s).

Syntax : RMPRequest.updateFileAddLane(fileIds, laneIds);

Parameters :

Name Type Description
fileIds Array a list of files identifiers.
laneIds Array a list of lane identifiers.

Returns : The list of lanes and users with the appropriate right for each file in JSON: ie: {:{"user":{"READ":[user_ids], "WRITE":[user_ids]}, "lane":{"READ":[lane_ids], "WRITE":[lane_ids]}...}

Type : JSON object

Example :

1
2
3
4
<@script env="js">
var j = RMPRequest.updateFileAddLane(["fb090250-b571-4aba-a25a-77a996fe72ee"],[53762810]);
RMPData.setOutput(j);
< /@script >

80. Update File Add User with (fileIds, userIds)

Add users allowed to WRITE/DELETE the file(s).

Syntax : RMPRequest.updateFileAddUser(fileIds, userIds);

Parameters :

Name Type Description
fileIds Array a list of file identifiers.
userIds Array a list of either user identifiers or user logins

Returns : The list of lanes and users with the appropriate right for each file in JSON: ie: {:{"user":{"READ":[user_ids], "WRITE":[user_ids]}, "lane":{"READ":[lane_ids], "WRITE":[lane_ids]}...}

Type : JSON object

Example :

1
2
3
4
<@script env="js">
var j = RMPRequest.updateFileAddUser(["fb090250-b571-4aba-a25a-77a996fe72ee"],[66021605]);
RMPData.setOutput(j);
< /@script >

81. Update File Add User with (fileIds)

Add connected/login user allowed to WRITE/DELETE the file(s).

Syntax : RMPRequest.updateFileAddUser(fileIds);

Parameters :

Name Type Description
fileIds Array a list of files identifiers.

Returns : The list of lanes and login users with the appropriate right for each file in JSON: ie: {:{"user":{"READ":[user_ids], "WRITE":[user_ids]}, "lane":{"READ":[lane_ids], "WRITE":[lane_ids]}...}

Type : JSON object

Example :

1
2
3
4
<@script env="js">
var j = RMPRequest.updateFileAddUser(["fb090250-b571-4aba-a25a-77a996fe72ee"]);
RMPData.setOutput(j);
< /@script >

82. Update File Remove Lane with (fileIds, laneIds)

Remove lanes allowed to WRITE/DELETE the file(s).

Syntax : RMPRequest.updateFileRemoveLane(fileIds, laneIds);

Parameters :

Name Type Description
fileIds Array a list of files identifiers.
laneIds Array a list of lane identifiers.

Returns : The list of lanes and users with the appropriate right for each file in JSON: ie: {:{"user":{"READ":[user_ids], "WRITE":[user_ids]}, "lane":{"READ":[lane_ids], "WRITE":[lane_ids]}...}

Example :

1
2
3
4
<@script env="js">
var j = RMPRequest.updateFileRemoveLane(["03acf9f2-609f-4cb4-bcbe-17e4005e1fea"],[53818190]);
RMPData.setOutput(j);
< /@script >

83. Update File Remove Lane with (fileIds)

Remove the current lane(lane of the request) allowed to WRITE/DELETE the file(s).

Syntax : RMPRequest.updateFileRemoveLane(fileIds);

Parameters :

Name Type Description
fileIds Array a list of files identifiers.

Returns : The list of users and lane of the request with the appropriate right for each file in JSON: ie: {:{"user":{"READ":[user_ids], "WRITE":[user_ids]}, "lane":{"READ":[lane_ids], "WRITE":[lane_ids]}...}

Example :

1
2
3
4
<@script env="js">
var j = RMPRequest.updateFileRemoveLane(["03acf9f2-609f-4cb4-bcbe-17e4005e1fea"]);
RMPData.setOutput(j);
< /@script >

84. Update File Remove User with (fileIds, userIds)

Remove users allowed to WRITE/DELETE the file(s).

Syntax : RMPRequest.updateFileRemoveUser(fileIds, userIds);

Parameters :

Name Type Description
fileIds Array a list of file identifiers.
userIds Array a list of either user identifiers or user logins

Returns : The list of lanes and users with the appropriate right for each file in JSON: ie: {:{"user":{"READ":[user_ids], "WRITE":[user_ids]}, "lane":{"READ":[lane_ids], "WRITE":[lane_ids]}...}

Type : JSON object

Example :

1
2
3
4
<@script env="js">
var j = RMPRequest.updateFileRemoveUser(["fb090250-b571-4aba-a25a-77a996fe72ee"],[66021605]);
RMPData.setOutput(j);
< /@script >

85. Update File Remove User with (fileIds)

Remove connected/login user allowed to WRITE/DELETE the file(s).

Syntax : RMPRequest.updateFileRemoveUser(fileIds);

Parameters :

Name Type Description
fileIds Array a list of files identifiers.

Returns : The list of lanes and login users with the appropriate right for each file in JSON: ie: {:{"user":{"READ":[user_ids], "WRITE":[user_ids]}, "lane":{"READ":[lane_ids], "WRITE":[lane_ids]}...}

Type : JSON object

Example :

1
2
3
4
<@script env="js">
var j = RMPRequest.updateFileRemoveUser(["fb090250-b571-4aba-a25a-77a996fe72ee"]);
RMPData.setOutput(j);
< /@script >


RMPUser

Methods for User

86. Get Application

Get the list of applications authorized to a user. This method can be used in a web interface.

Syntax : RMPUser.getApplications(login, appContext, theMode, isTagged);

Parameters :

Name Type Argument Default Description
login String Optional current user's login User login/email. Current user by default
appContext String Optional web Context in which the application can be used: web, mobile or tablet.
theMode String Optional current execution mode LIVE will return the applications in LIVE version, ACCEPTANCE the applications in both LIVE and ACCEPTANCE versions, TEST will return an empty array. By default, this is the current execution mode.
isTagged Boolean Optional false return the JSONObject representing the list of user interfaces group by tag if true

Returns : List of applications

Type : Array

Example :

1
2
3
4
<@script env="js">  
var res =  RMPUser.getApplications("user@runmyprocess.com")
RMPData.setOutput(res);
< /@script >

87. Get Lanes

Get the list of lanes a user pertains to.

Get the list of lanes a user pertains to in the current execution mode context. This method can be used in a web interface. When called from a LIVE or TEST context, this method will return the list of lanes the user pertains to in LIVE. When called from an ACCEPTANCE context, this method will return the list of lanes the user pertains to in ACCEPTANCE.

Syntax : RMPUser.getLanes(login);

Parameters :

Name Type Argument Description
login String Optional User login/email. Current user by default

Returns : Lane descriptor

Type : Object

Example :

1
2
3
4
<@script env="js">
var res =  RMPUser.getLanes("user@runmyprocess.com");
RMPData.setOutput(res);
< /@script >

88. Get Lane Users

Get the list of users pertaining to a lane.

Get the list of users pertaining to a lane (result is paginated) in the current execution mode context. When called from a LIVE or TEST context, this method will return the list of LIVE users of a lane. When called from an ACCEPTANCE context, this method will return the list of ACCEPTANCE users of a lane.

Syntax : RMPUser.getLaneUsers(poolId, laneId, pageSize, first);

Parameters :

Name Type Description
poolId Integer Pool identifier
laneId Integer Lane identifier
pageSize Integer Number of users returned
first Integer Index for pagination

Returns : List of user's descriptors

Type : Array

Example :

1
2
3
4
<@script env="js">
var res =  RMPUser.getLaneUsers(1,5701,1,1);
RMPData.setOutput(res);
< /@script >

89. Get Manager

Get the user's manager.

Get a manager N levels above the designed user. Only searches within a hierarchy of organizations. Only the LIVE configuration of lanes will be considered. Therefore this method's result is independent of the execution mode context.

Syntax : RMPUser.getManager(login, level);

Parameters :

Name Type Argument Default Description
login String User login / email.
level Integer Optional 1 Number of levels of hierarchy

Throws : No manager found

Returns : Login/Email of a manager

Type : String

Example :

1
2
3
4
<@script env="js">
var res =  RMPUser.getManager("user@rmp.com",0);
RMPData.setOutput(res);
< /@script >

90. Get User Data

Get a user's basic information (id, name, profile) from its login.

Syntax : RMPUser.getUserData(login);

Parameters :

Name Type Description
login String The mail ID of the recipient

Returns : Information of the given User.

Type : Map

Example :

1
2
3
<@script env="js">
RMPUser.getUserData("Mail_ID");
< /@script >

91. Get User Lanes

Get the list of users pertaining to a lane.

Syntax : RMPUser.getUserLanes(login);

Parameters :

Name Type Description
login String The mail ID of the recipient

Returns : Role Name and Role ID.

Type : List

Example :

1
2
3
<@script env="js">
RMPUser.getUserLanes("Mail_ID");
< /@script >

92. Get User Metadata

Get the metadata of the active user.

Syntax : RMPUser.getUserMetaData();

Parameters : None

Returns : User Metadata

Type : Map

Example :

1
2
3
<@script env="js">
RMPUser.getUserMetaData();
< /@script >

93. Get User Metadata with (login)

Get the metadata of the user.

Syntax : RMPUser.getUserMetaData(login);

Parameters :

Name Type Description
login String The mail ID of the recipient

Returns : User Metadata

Type : Map

Example :

1
2
3
<@script env="js">
RMPUser.getUserMetaData("Mail_ID");
< /@script >

94. Get User Preferences

Get the preferences associated with a user.

Syntax : RMPUser.getUserPreferences(login);

Parameters :

Name Type Argument Description
login String Optional Login of the user for which the preferences shall be retrieved. By default, preferences are retrieved for the current user.

Returns : User's preferences

Type : Object

Example :

1
2
3
4
<@script env="js">
var res =  RMPUser.getUserPreferences("user@rmp.com");
RMPData.setOutput(res);
< /@script >

95. Has Right In Lane

Check if a user belongs to a lane in the current execution mode context. When called from a LIVE or TEST context, this method will check the LIVE list of users of the lane. When called from an ACCEPTANCE context, this method will check the ACCEPTANCE list of users of the lane.

Syntax : RMPUser.hasRightInLane(login, laneId);

Parameters :

Name Type Argument Description
login String Optional User login / email. Current user by default.
laneId Integer Lane identifier

Returns : true if the user belongs to the indicated lane, false if the user is not connected or if he/she does not belong to the lane

Type : Boolean

Example :

1
2
3
4
<@script env="js">
var res =  RMPUser.hasRightInLane("user@runmyprocess.com",5701);
RMPData.setOutput(res);
< /@script >

96. Impersonate

Impersonate another user on the same account: only allowed when the process current user is an account's admin.

Syntax : RMPUser.impersonate(login);

Parameters :

Name Type Argument Description
login String Optional Login / email of the different user to impersonate.

Throws : Impersonification is not allowed for user

Returns : Login of the impersonated user

Type : String

Example :

1
2
3
4
5
<@script env="js">
var f = RMPUser.impersonate("EmailID");
var md = RMPUser.getUserMetaData();
RMPData.setOutput(md);
< /@script >

97. Save User Metadata

Modify the metadata of a user.

Syntax : RMPUser.saveUserMetaData(login, metadataJSON);

Parameters :

Name Type Argument Description
login String Optional User login/email. Current user by default
metadataJSON Integer New metadata

Returns : Login of the user

Type : String

Example :

1
2
3
4
5
<@script env="js">
var newMetadataJSON = {"name":"user", "age":22, "car":null};
var res =  RMPUser.saveUserMetaData("user@runmyprocess.com", newMetadataJSON);
RMPData.setOutput(res);
< /@script >

98. Save User Preferences

Save the preferences associated with a user.

Syntax : RMPUser.saveUserPreferences(userPreferences)

Parameters :

Name Type Description
userPreferences object User's preferences

Returns : User login ID.

Type : String

Example :

1
2
3
4
<@script env="js">
var res =  RMPUser.saveUserPreferences({"elementTest":"DT","Login":"user"});
RMPData.setOutput(res);
< /@script >


RMPUtilities

Methods for Utilities

99. CSV To JSON

Converts an CSV input into JSON format.

Syntax : RMPUtilities.csvToJson(object, optionList);

Parameters :

Name Type Description
object String Input file
optionList Map Options to be used for defining the JSON parsing behavior

Returns : JSON file.

Type : String

Example :

1
2
3
4
<@script env="js">
var result = RMPUtilities.csvToJson( '1,true,hello\n2,false,world', {});
RMPData.setOutput(result);
< /@script >

100. Decrypt

Returns the decrypted version of the string provided in input. - This method can be used in a web interface.

Syntax : RMPUtilities.decrypt(input, vector, keystring);

Parameters :

Name Type Description
input String Encrypted text
vector String The initialization vector
keystring String Key to decrypt the ciphered text

Returns : Decrypted String.

Type : String

Example :

1
2
3
4
<@script env="js">
var result = RMPUtilities.decrypt("HtcLaNk0xk/G+DjClefgdA==","LqME74+sChTIcYsaUMkBPw==","0ckdURPMf4P4ismngaFgZbX3CGzJCyuR6hTgEAL9RTc=");
RMPData.setOutput(result);
< /@script >

101. Encrypt

Returns the encrypted version of the string provided in input. - This method can be used in a web interface.

Syntax : RMPUtilities.encrypt(input, key);

Parameters :

Name Type Description
input String Input text to encrypt
key String A variable value to encrypt the text

Returns : A result containing the initialization vector (iv field) and the encrypted version of input (encrypted field).

Type : Map

Example :

1
2
3
4
<@script env="js">
var result = RMPUtilities.encrypt('hello world', 'c7ZOu5rr3fMHTOAAwwlFD049PBVAZ6SU8UJuU3A9lVM=');
RMPData.setOutput(result);
< /@script >

102. JSON To CSV

Convert the JSON input array to CSV format

Converts an array of either JSON objects or arrays to a CSV string. The contained JSON objects must only consist of simple types - no nested objects are allowed. Arrays also must only consist of simple types. The line end is CRLF.

Syntax : RMPUtilities.jsonToCsv(input, options);

Parameters :

Name Type Argument Description
input Object User login/email. Current user by default
options Object Optional Options to be used for defining the JSON parsing behavior

Returns : The resulting CSV data as a string

Type : String

Example :

1
2
3
4
<@script env="js">
var result = RMPUtilities.jsonToCsv( [["1","true","hello"],["2","false","world"]], {});
RMPData.setOutput(result);
< /@script >

103. RSA Hash

Generating RSA digital signature specifying the algorithm & encoding.

Syntax : RMPUtilities.rsaHash(input, options);

Parameters :

Name Type Argument Default Description
data String Data to be signed
key String The private key readers supports PEM files with PKCS#8 or PKCS#1 encodings. It doesn't support encrypted PEM files
algorithm String Optional SHA256 SHA256 (default), SHA1 or MD5
encoding String Optional BASE64 New BASE64 (default), BASE64URL or HEXA

Returns : Data signed

Type : String

Example :

1
2
3
4
5
6
7
<@script env='js'>
var key ='-----BEGIN RSA PRIVATE KEY-----\n' +

     '-----END RSA PRIVATE KEY-----';
var j = RMPUtilities.rsaHash('hello world', key, 'SHA256', 'HEXA');
RMPData.setOutput(j);   
< /@script >

104. UUID

Generate a universally unique identifier or UUID

Syntax : RMPUtilities.uuid();

Parameters : None

Returns : UUID value

Type : String

Example :

1
2
3
4
<@script env="js">
var result = RMPUtilities.uuid();  
RMPData.setOutput(result);
< /@script >