process
Provides Functions regarding process executions and process timers.
Methods
createProcessHistoryRequest
createProcessHistoryRequest():
GetProcessHistoryRequest
Creates a new empty request object to query entries of the process history.
If no further settings are made to the request, the query returns all entries of the process history, sorted by start time in descending order.
The provided setter methods can be used to specify additional search parameters and set options for paging.
Example:
Returns
a new empty request object to query entries of the process history.
Example
// Create a new process history request
var request = process.createProcessHistoryRequest();
// Specify the attributes of searched entries
request.setProcessNames(["myProcess_1", "myProcess_2"]) // List of process names
.setExecutionUIDs(["P-01", "P-02"]) // List of executionUIDs
.setSystemIDs(["default", "default-bg"]) // List of ADITO systems
.setServerUIDs(["default-F0A2", "default-bg-DCA3"]) // List of unique server UIDs
.setFromStartTime(Date.now()); // Earliest start time of the process in ms
// Specify the parameters for paging
request.setPagingOffset(0) // Start index of the page
.setPagingLimit(10); // Element count of the page
// Additional parameters.
request.setProcessHistoryLimit(5) // Defines how many entries per process are returned
.useAscendingOrder() // Sorts all results in ascending order based on the start time
.useDescendingOrder() // Sorts all results in descending order based on the start time (default)
.useNoOrder(); // Results are returned in no specific order
var historyEntries = getProcessHistory(request);
createStartAsyncConfig
createStartAsyncConfig():
StartProcessAsyncConfig
Create and return a config object to start an asynchronous process via startAsync
The value for "ProcessName" is mandatory. All other elements, if not set, will be used with their defaultvalues.
Defaultvalues:
ThreadPriority: THREADPRIORITY_NORM
TimerType: TIMERTYPE_SERVER_RUN
Returns
StartProcessAsyncConfig Config Object to set the values via the available setters
createStartConfig
createStartConfig():
StartProcessConfig
Create and return a config object to start a synchronous process via start
The value for "ProcessName" is mandatory.
Returns
StartProcessConfig Config Object to set the values via the available setters
createStartScriptConfig
createStartScriptConfig():
StartScriptConfig
Create and return a config object to start an inline script via startScript
The value for "ProcessName" is mandatory.
Returns
StartProcessConfig Config Object to set the values via the available setters
createStartTimedConfig
createStartTimedConfig():
StartProcessTimedConfig
Create and return a config object to start a timed process via startTimed
The values for "ProcessName" and "Identifier" are mandatory. All other elements, if not set, will be used with their defaultvalues.
Defaultvalues:
ThreadPriority: THREADPRIORITY_NORM
TimerType: TIMERTYPE_SERVER_RUN
Returns
StartProcessTimedConfig Config Object to set the values via the available setters
execute()
execute(
pName,pLocalVariables):string
This method can be used to execute a process.
This process will not be executed within the current frame context, but directly within the client (or server) context.
This means that the $sys.currentwindow and $sys.currentimagevariables are not available.
To execute a process within the current context, use the appropriate functions. This process will not prevent the client from being executed.
Parameters
string | number | booleanThe name of the process to be executed.
anyA map with variables (key, value – values only as strings) that are passed to the process as $local variables. The name of the corresponding variable in the process is then "$local.key". 'Null' if you do not want to pass variables.
Returns
stringThe result as a string, or 'null' if no result exists.
Deprecated
Deprecated since 2020.0.1. Use process.start(pConfig) instead.
Throws
May throw an exception.
Example
var result = process.execute("testprocess", null);
question.showMessage(result);
//"testprocess" is a global process with
//the following code: return.string("Hello world!"); **//object data is passed**
var lunch = new Array();
lunch["tasty"] = "Tom Yum";
lunch["restaurant"] = "Siam";
process.execute("test_process", lunch);
executeAsync()
executeAsync(
pName,pLocalVariables,pShowErrorDialog,pUser,pThreadPriority,pTimerType?):void
Runs a process in the background. If this function is executed in the client context, then its variables are available.
Parameters
string | number | booleanThe name of the process to run.
anyA map with variables (key, value only string) that are passed to the process as $local variables. The name of the corresponding variable in the process is then "$local.[key] ". 'Null' if you do not want to pass variables.
boolean'true' indicates, if possible, an error message can be used only in the client context.
string | number | booleanThe title of the user under which name the process is running. Used only in server context.
numberThe priority of the thread, see process.THREADPRIORITY_*
numberThe timer type, see process.TIMERTYPE_*.
Returns
voidDeprecated
Deprecated since 2020.0.1. Use process.startAsync(pConfig) instead.
Throws
May throw an exception.
executeScript()
executeScript(
pIdentifier,pScript,pLocalVariables,pAlias):string
Executes the code you passed. The execution works the same way as for process.execute(), but the code is passed directly.
Parameters
string | number | booleanAn identifier that can be used to recognize the script
string | number | booleanThe code to be executed. Imports within the script must be separated by "\r\n".
anyA map with variables that are passed to the process as $local variables. The name of the corresponding variable in the process is then "$local.[Key]". 'Null' if you do not want to pass variables.
string | number | booleanThe alias to be used for the script; 'null' for the current context alias.
Returns
stringThe result as a string, or 'null' if no result exists.
Deprecated
Deprecated since 2020.0.1. Use process.startStart(pConfig) instead.
Throws
May throw an exception.
Example
var script = "import(\"system.result\");\r\nimport(\"system.vars\");\r\nimport(\"system.logging\");\r\n logging.log(vars.getString(\"$local.result\"));\r\nresult.string(vars.getString(\"$local.result\"));";
process.executeScript("[evalscript]", script, {"result": "test"}, null); // returns "test"
executeTimer()
executeTimer(
pIdentifier,pName,pInterval,pRunImmediately,pShowErrorDialog,pTimerType,pUser,pKeepJDito,pThreadPriority):void
This method executes a global JDito process as a timer.
This process will not be executed within the current context, but within the client or server context.
This means that the $sys.currentwindow and $sys.currentimage variables are not available.
To execute a process within the current context, use the appropriate functions.
Parameters
string | number | booleanThe unique name of the timer.
string | number | booleanThe name of the process to be executed.
numberThe interval, in milliseconds, in which the process is to be executed.
booleanIf 'true', the process will be run once immediately after starting the timer.
boolean"true" shows an error message if an error occurs (if possible, only if TIMERTYPE_CLIENT_RUN).
numberThe timer type, see process.TIMERTYPE_*.
string | number | booleanThe user under whose name the process will be executed. 'Null' for anonymous. Not for TIMERTYPE_CLIENT_RUN.
boolean'true' will create a JDito instance only once and then re-use it again and again (for server processes).
numberThe priority of the thread: process.THREADPRIORITY_*.
Returns
voidDeprecated
Deprecated since 2020.0.1. Use process.startTimed(pConfig) instead.
Throws
May throw an exception.
executeTimer(
pIdentifier,pName,pInterval,pRunImmediately,pShowErrorDialog,pTimerType,pUser,pKeepJDito,pThreadPriority,pLocalVariables):void
This method executes a global JDito process as a timer.
This process will not be executed within the current context, but within the client or server context.
This means that the $sys.currentwindow and $sys.currentimage variables are not available.
To execute a process within the current context, use the appropriate functions.
Example
process.executeTimer("PENDING_TIMER_STARTER", "start_timer", datetime.ONE_SECOND * 30, true, false, process.TIMERTYPE_SERVER, null, false, process.THREADPRIORITY_HIGH);
Example
process.executeTimer("PENDING_TIMER_STARTER", "start_timer", datetime.ONE_SECOND * 30, true, false, process.TIMERTYPE_SERVER, null, false, process.THREADPRIORITY_HIGH);
Parameters
string | number | booleanThe unique name of the timer.
string | number | booleanThe name of the process to be executed.
numberThe interval, in milliseconds, in which the process is to be executed.
booleanIf 'true', the process will be run once immediately after starting the timer.
boolean"true" shows an error message if an error occurs (if possible, only if TIMERTYPE_CLIENT_RUN).
numberThe timer type, see process.TIMERTYPE_*.
string | number | booleanThe user under whose name the process will be executed. 'Null' for anonymous. Not for TIMERTYPE_CLIENT_RUN.
boolean'true' will create a JDito instance only once and then re-use it again and again (for server processes).
numberThe priority of the thread: process.THREADPRIORITY_*.
anyA map with variables (key, value only string) that are passed to the process as $local variables. The name of the corresponding variable in the process is then "$local.[key] ". 'Null' if you do not want to pass variables.
Returns
voidDeprecated
Deprecated since 2020.0.1. Use process.startTimed(pConfig) instead.
Throws
May throw an exception.
existsTimer
existsTimer(
pIdentifier):boolean
Checks whether a timer with the specified identifier already exists.
Parameters
string | number | booleanThe identifier of the timer process.
Returns
boolean'true' if the timer exists.
Throws
May throw an exception.
Example
var exists = process.existsTimer("WORKFLOW");
getActiveTimers
getActiveTimers():
string[]
Returns the IDs of the active timers.
Returns
string[]The IDs of the active timers as an array.
Throws
May throw an exception.
Example
var timers = process.getActiveTimers();
getExecutionHistory
getExecutionHistory(
pProcessName):ProcessExecutionLog[]
Returns information about the execution history of the given processes (by name).
Parameters
string[]the process names as array
Returns
an array of ProcessExecutionLog objects
Throws
May throw an exception.
getExecutionHistoryByUID
getExecutionHistoryByUID(
pExecutionUID):ProcessExecutionLog[]
Returns information about the execution history of the given process executions (by uid).
Parameters
string[]the process execution uids as array
Returns
an array of ProcessExecutionLog objects
Throws
May throw an exception.
getMetadataMultiple
getMetadataMultiple(
pOnlyActives):ProcessInfos[]
Loads infos about all processes specified as VARIANT_EXECUTABLE. For further infos see getMetadataSingle
Parameters
booleanIf true only active executable processes are returned otherwise all of them
Returns
Array of JScriptProcess.ProcessInfos
Throws
AditoException
getMetadataSingle
getMetadataSingle(
pProcessName):ProcessInfos
Loads infos about a timed process. Use the getters of the returned JScriptProcess.ProcessInfos Object to access the desired infos or use JScriptProcess.ProcessInfos.getAsJson to get it as JSON object.
Parameters
string | number | booleanName of the process added as timer
Returns
JScriptProcess.ProcessInfos Object containg infos or null if the desired process couldn't be found
Throws
AditoException
getProcesses
getProcesses(
pVariantNames):string[]
Returns a list of process names having the specified variant
Parameters
string[]List of the variants for which the processes should be loaded
Returns
string[]List of process names
Throws
AditoException
getProcessHistory
getProcessHistory(
pProcessHistoryRequest):ProcessExecutionLog[]
Returns information about the execution history of all processes matching the given request object.
Example:
Parameters
The process history request for which the matching entries are returned.
Returns
An array of ProcessExecutionLog objects that match the conditions of the request.
Throws
May throw an exception.
Example
var request = process.createProcessHistoryRequest()
.setProcessNames(["myProcess_1", "myProcess_2"])
.setSystemIDs(["default"])
.setPagingOffset(0)
.setPagingLimit(10);
var historyEntries = getProcessHistory(request);
getTimedProcessConfiguration
getTimedProcessConfiguration(
pTimerId):StartProcessTimedConfig
Loads a saved timed process configuration which has been saved using storeTimedProcessConfiguration(...)
Important: The values localVariables and runImmediately are NOT persisted, set again if necessary
Parameters
string | number | booleanId of an existing timer in the format of [ProcessName].process.
Returns
The config containing the data for the specific timer or null if timerId doesn't exist
Throws
AditoException
isRunningTimer
isRunningTimer(
pIdentifier):boolean
Checks whether a timer with the specified identifier is currently being executed.
Parameters
string | number | booleanThe identifier of the timer process.
Returns
boolean'true' if it is being executed; otherwise 'false'.
Throws
May throw an exception.
Example
var wfrun = process.existsTimer("WORKFLOW");
if(wfrun)
{
question.showMessage(process.isRunningTimer("WORKFLOW");
}
start
start(
pConfig):string
This method can be used to execute a process.
Use createStartConfig to create a configuration.
Parameters
Returns
stringThe result as a string, or 'null' if no result exists.
Throws
AditoIllegalStateException
Example
var startConfig = process.createStartConfig()
.setName("MyProcessName") var result = process.start("myProcessName", null);
**//Object that contains the processes local variables**
var localVars = new Array();
localVars["myVar1"] = "content1";
localVars["myVar2"] = "content2";
var startConfig = process.createStartConfig()
.setName("MyProcessName")
.setLocalVariables(localVars) process.start(startConfig);
Execution always happens on the server it has been started on.
Throws
AditoIllegalArgumentException
Throws
May throw an exception.
startAsync
startAsync(
pConfig):void
This method can be used to start an asynchronous process.
Use createStartAsyncConfig to create a configuration.
Parameters
Returns
voidThrows
AditoIllegalStateException
Example
var startConfig = process.createStartAsyncConfig()
.setName("MyProcessName") var result = process.startAsync("myProcessName", null);
**//Object that contains the processes local variables**
var localVars = new Array();
localVars["myVar1"] = "content1";
localVars["myVar2"] = "content2";
var startConfig = process.createStartAsyncConfig()
.setName("MyProcessName")
.setLocalVariables(localVars) process.startAsync(startConfig);
Execution always happens on the server it has been started on.
Throws
AditoIllegalArgumentException
Throws
May throw an exception.
startScript
startScript(
pConfig):string
Executes the passed script.
Parameters
Returns
stringThe result as a string, or 'null' if no result exists.
Throws
AditoIllegalStateException
Throws
AditoIllegalArgumentException
Throws
May throw an exception.
startTimed
startTimed(
pConfig):void
This method can be used to start a timed process.
Use createStartTimedConfig to create a configuration.
If the intervall is lower or equal to 0, the process will be started using startTimed with the desired identifier and defaultvalues.
The Process will be executed on the specified servers. This timed execution works in a Server Cluster. It is recommended to use the Cloud Manager as it uses an active push mechanism to broadcast the processes instead of polling.
Parameters
Returns
voidThrows
AditoException
Example
var startConfig = process.createStartAsyncConfig() <br/>.setName("MyProcessName") var result = process.startTimed("myProcessName", null);
<b>//Object that contains the processes local variables</b>
var localVars = new Array();
localVars["myVar1"] = "content1";
localVars["myVar2"] = "content2";
<br/> var startConfig = process.createStartConfig() <br/>.setName("MyProcessName") <br/>.setLocalVariables(localVars) process.startTimed(startConfig);
stopTimer
stopTimer(
pIdentifier):void
Stops the timer with the specified identifier. If no timer with the identifier exists, nothing will happen.
Parameters
string | number | booleanThe identifier of the timer process.
Returns
voidThrows
May throw an exception.
Example
process.stopTimer("WORKFLOW");
storeTimedProcessConfiguration
storeTimedProcessConfiguration(
pConfig):void
Saves a timed process configuration. To load the configuration use getTimedProcessConfiguration(...) with the timerId
Important: The values localVariables and runImmediately are NOT persisted
Parameters
Returns
voidThrows
AditoException
Properties
INTERVAL_UNIT_DAY
numberUnit: Day
INTERVAL_UNIT_HOUR
numberUnit: Hour
INTERVAL_UNIT_MINUTE
numberUnit: Minute
INTERVAL_UNIT_MONTH
numberUnit: Month
INTERVAL_UNIT_SECOND
numberUnit: Second
INTERVAL_UNIT_WEEK
numberUnit: Week
STARTTYPE_INTERNAL
stringInternal process, which was started by the server itself.
STARTTYPE_MANUAL
stringThe process was manually triggered by a user, or an interface.
STARTTYPE_TIMER
stringThe process was triggered by a configured timer.
THREADPRIORITY_HIGH
numberPriority of the current thread in process.executeTimer(): high priority
THREADPRIORITY_LOW
numberPriority of the current thread in process.executeTimer(): low priority
THREADPRIORITY_NORM
numberPriority of the current thread in process.executeTimer(): normal priority
THREADPRIORITY_VERYHIGH
numberPriority of the current thread in process.executeTimer(): very high priority
THREADPRIORITY_VERYLOW
numberPriority of the current thread in process.executeTimer(): Very low priority
TIMERTYPE_CLIENT_RUN
numberTimertyp: This timer exists once per client; it runs as long as the client is running.
TIMERTYPE_CLUSTER
numberTimertyp: This timer exists once per cluster; it is started automatically after a cluster failure. Last run is saved when the cluster is stopped and is scheduled to restart when the server is restarted.
TIMERTYPE_SERVER
numberTimertyp: This timer exists once per server; it is started automatically after a server failure. Last run is saved when the server is stopped and is scheduled to restart when the server is restarted. In Multi-Server environments, most like this is not the desired timer type as processes will be run on every server. TIMERTYPE_CLUSTER ist a better choice in the vast majority of cases.
TIMERTYPE_SERVER_RUN
numberTimertyp: This timer exists once per server; it runs as long as the server is running. In Multi-Server environments, most like this is not the desired timer type as processes will be run on every server. TIMERTYPE_CLUSTER ist a better choice in the vast majority of cases.
VARIANT_EXECUTABLE
stringVariant: Executable
VARIANT_LIBRARY
stringVariant: Library
VARIANT_NONE
stringVariant: None
VARIANT_SYSTEM
stringVariant: System
VARIANT_WEBSERVICE
stringVariant: Webservice
VARIANT_WORKFLOW
stringVariant: Workflow