Request

Functions to manage a process request

Methods

get_access_url(includeProtocol) → {string}

Get the URL of the RunMyProcess server.

Parameters:
Name Type Description
includeProtocol boolean Whether or not including the protocol in the URL
Returns:
URL with or without protocol
Type
string
Example
${get_access_url(true)} = https://live.runmyprocess.com/
     ${get_access_url(false)}  = live.runmyprocess.com/
  

get_custom_list(id) → {array}

Get the content of a custom list.

Parameters:
Name Type Description
id string Identifier of a custom list
Returns:
List un a JSONArray format
Type
array

get_next_url(stepId, is_public, context) → {string}

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.
Parameters:
Name Type Argument Default Description
stepId integer The id of the step as defined in the process design
is_public boolean Use a public task template or not
context string <optional>
web If context=mobile, the generated URL will be adapted to the the RunMyApp environment
Returns:
Task URL
Type
string

get_parent_params() → {object}

Retrieves all parameters from the parent process request.

Retrieves all parameters from the parent process request. Do not indicate any target parameter name to inject all parameters directly into the context of the current process request.
Returns:
Parent process' parameters
Type
object

get_project_metadata(projectId) → {object}

Get the metadata of a project.

Parameters:
Name Type Argument Description
projectId integer <optional>
Identifier of the project. By default the project of the current process request is used.
Throws:
Project not found
Returns:
Project metadata
Type
object

get_request_info(id) → {object}

Describe a process request.

Parameters:
Name Type Argument Description
id 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

get_task_url(is_public) → {string}

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.
Parameters:
Name Type Description
is_public boolean Use a public task template or not
Returns:
Task URL
Type
string

inject_params() → {object}

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

Returns:
Result of the last executed task
Type
object

lock(name, timeout) → {string}

Lock a resource.

Create 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.
Parameters:
Name Type Argument Description
name string Name of the lock
timeout integer <optional>
Maximum duration to wait for the lock to be taken (milliseconds)
See:
  • request#unlock
Throws:
Timeout while waiting for lock
Returns:
Name of the lock
Type
string

next_value(name) → {integer}

Get the next value of a named and persistent counter.

Get the next value of a named and persistent counter. The counter is created and initialized at 0 id it doesn't exists
Parameters:
Name Type Description
name string Name of the counter
Throws:
Counter already being modified, cannot increment it
Returns:
Next value
Type
integer

P_add_user_to_lane(laneId, userId) → {array}

Add a user to the given runtime lane.

Parameters:
Name Type Description
laneId integer Id of the lane
userId integer/string Id or login of the user
See:
  • request#P_remove_user_from_lane
Returns:
List of the users id in the lane
Type
array

P_delete_project_vault() → {boolean}

Delete a project vault

See:
  • request#P_save_project_vault
Returns:
True if the project vault has been found and deleted, false otherwise.
Type
boolean

P_get_oauth2_token(service) → {object}

Retrieve an OAuth2 service token

Parameters:
Name Type Description
service string Name of the OAuth2 service which token is to be retrieved
See:
  • request#P_save_oauth2_token
Returns:
The OAuth2 token associated to 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: `${P_get_oauth2_token("my_service").access_token}`. An OAuth2 service token value depends on the current request execution mode.
Type
object

P_load_project_vault() → {object}

Retrieve the project vault associated to the project containing the current request

See:
  • request#P_save_project_vault
Returns:
The current request project vault. A project vault value depends on the current request execution mode.
Type
object

P_log(level, message) → {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.
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

P_log(message) → {string}

Equivalent to P_log('FINEST', message).

Parameters:
Name Type Description
message string Message to be logged.
Returns:
Logged message
Type
string

P_remove_user_from_lane(laneId, userId) → {array}

Remove a user from the given runtime lane.

Parameters:
Name Type Description
laneId integer Id of the lane
userId integer/string Id or login of the user
See:
  • request#P_add_user_to_lane
Returns:
List of the users id in the lane
Type
array

P_save_oauth2_token(service, token) → {object}

Modify or create an OAuth2 service token

Parameters:
Name Type Description
service string Name of the OAuth2 service which token is to be modified
token object Token object associated to the specified service. This object must contain at least a field name access_token containing the OAuth2 access token. It may also contain a refresh_token field and an expires_in field, containing an OAuth2 refresh token and a token lifetime duration, or any extra fields.
See:
  • request#P_get_oauth2_token
Returns:
The updated token associated to the specified service.
Type
object

P_save_project_vault(vault) → {object}

Modify or create a project vault

Parameters:
Name Type Description
vault object An object representing the vault associated to project containing the current request. This object may contain any fields.
See:
  • request#P_load_project_vault
Returns:
The updated project vault.
Type
object

P_set_request_status(statusCode)

Set the status of the current request to the statusCode.

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

save_custom_list(listId, data) → {array}

Update a custom list with a new content.

Parameters:
Name Type Description
listId string Identifier of the custom list to be modified
data array New content of the custom list
Throws:
Custom list not found
Returns:
New content
Type
array

throw(message)

Throw an error.

Parameters:
Name Type Argument Description
message string <optional>
Error message
Throws:
An error with the given error message

unlock(name) → {string}

Release a lock.

Release a lock acquired with `${lock(name)}`.
Parameters:
Name Type Description
name string Name of the lock
See:
  • request#lock
Returns:
Name of the lock
Type
string