Job Definition
Create and Edit
- Go to Side Menu > Batch. Select the
"Job Definition"
button at the top of the screen. (By default, the"Job Definition"
tab is already selected.) - A list of jobs is displayed.
- Click the
"ADD"
-"NEW"
button in the upper right corner of the screen. - A screen for defining jobs opens.
- Job definitions consist of three menus:
"General Settings,"
"Trigger,"
and"Script,"
and each menu can be selected from the left tree. - Describe the contents of each menu item and click the
"Create"
button in the lower right corner to save the job definition and add it to the job definition list. - Job definitions can be edited by selecting
"Edit"
from the right menu of the list.
Tips
General Settings
Sets General Settings for job definitions.
Item | Specification | Explanation | Note |
---|---|---|---|
Job definition name | Required | Sets the name of the job definition. | Any string of up to 64 characters |
Description | Optional | Job Definition Description | Any string of up to 512 characters |
Execution timeout time | Optional | Job execution timeout time (seconds) No timeout if not specified If a timeout occurs, the job is terminated with a Failed status. | 60~2147483646 range integer |
Parameters | Optional | Parameters that can be referenced from the job’s script See the "Parameter Reference" section for details. | JSON |
Trigger
If you want to run a job according to a condition, set a trigger.
Item | Specification | Explanation | Note |
---|---|---|---|
Type | Optional | Specifies the type of trigger.
| Any string of up to 64 characters |
Trigger | Required | Set the trigger. Enter scheduled times with auto-repeat and fixed schedules. | |
Display time zone | Required | The next 10 scheduled execution times are displayed according to the trigger specification. This item specifies the time zone in which the above is to be expressed. |
Tips
Script
The script to be executed by the job is written in the editor area. As with actions, in addition to the main script, you can define JavaScript functions, SQL functions, and REST functions to be called from the main script.
Job Definition List
Created job definitions are displayed in the job definition list. The meaning of each item in the job definition list is as follows:
Item | Explanation |
---|---|
Job Definition | Displays the job definition name. |
Trigger | Displays the trigger name. |
Status | Displays the enabled/disabled status of the job definition. |
Next execution time | Displays the next scheduled execution time of the job. If the trigger is not set or disabled, it will not be displayed. |
Creation time | Displays the creation time of the job definition. |
Right menu | Open the context menu. The menu is: 1. "Run" , 2. "Detail" , 3. "Edit" , 4. "Enable/Disable" , 5. "Delete" , 6."Export" . |
Script Appendix
Writing batch scripts is basically the same as writing actions, but there are some differences. This section describes what can be done and what to keep in mind.
Parameter Reference
In the script, you can refer to the parameter contents (JSON) set by the user in the job definition as a "$param"
object.
Parameter description example 1
{
“param1”: 1234,
“param2”: true,
“param3”: [“Sun”, “Fri”],
“param4”: {
“test”: “test-value”
}
}
Example 1 of calling from a script
console.log($param.param1); // 1234
console.log($param.param2); // true
console.log($param.param3.join(”,”)); // Sun,Fri
console.log($param.param4.test); // test-value
Parameter description example 2 1234
Example 2 of calling from script console.log($param); // 1234
Environment Variable Reference
Specific environment information can be referenced in scripts as "$env"
objects. The properties of the $env object are as follows:
Property Name | Explanation | Type |
---|---|---|
BATCH_JOB_ID | ID of the job to be automatically assigned | string |
BATCH_JOB_DEFINITION_NAME | User-defined job definition name | string |
BATCH_JOB_NAME | Job name set by user | string |
Built-in Functions
Describes built-in functions that can be used within batch scripts.
Built-in Functions | Description | Usage examples |
---|---|---|
$fn.addUsers(param) | Refer to $fn.addUsers(param). | |
$fn.createFolder(path) | Refer to $fn.createFolder(path). | |
$fn.createUser(param) | Refer to $fn.createUser(param). | |
$fn.deleteFile(path) | Refer to $fn.deleteFile(path). | |
$fn.deleteFolder(path) | Refer to $fn.deleteFolder(path). | |
$fn.deleteUser(email) | Refer to $fn.deleteUser(email). | |
$fn.exit(exitCode) | Terminates the job with the specified exit code. Argument: Exit code (numeric) Return value: None Tips This built-in function is for batch scripts only. It cannot be used in actions. | try { // do something } catch(err) { console.error(err); $fn.exit(2); } |
$fn.getFile(path) | Refer to $fn.getFile(path). | |
$fn.getFileNames(path) | Refer to $fn.getFileNames(path). | |
$fn.getGroups(option) | Refer to $fn.getGroups(option). | |
$fn.getUsers(groupName?, option) | Refer to $fn.getUsers(groupName?, option). | |
$fn.listUsersByEmail(email,option) | Refer to $fn.listUsersByEmail(email,option). | |
$fn.listUsersByName(name,option) | Refer to $fn.listUsersByName(name,option). | |
$fn.putFile(path, obj) | Refer to $fn.putFile(path, obj). | |
$fn.removeUsers(param) | Refer to $fn.removeUsers(param). | |
$fn.resetPassword(param) | Refer to $fn.resetPassword(param). | |
$fn.sendMail(param) | Refer to $fn.sendMail(param). | |
$fn.updateUser(param) | Refer to $fn.updateUser(param). |
Import
Job definitions exported locally can be uploaded to the service. Select Import
from the Create
button in the upper right corner of the screen. Select a job definition folder from the Import
dialog and execute the upload.
Tips