Skip to content

Job Definition

Create and Edit

  1. 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.)
  2. A list of jobs is displayed.
  3. Click the "ADD"-"NEW" button in the upper right corner of the screen.
  4. A screen for defining jobs opens.
  5. Job definitions consist of three menus: "General Settings," "Trigger," and "Script," and each menu can be selected from the left tree.
  6. 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.
  7. Job definitions can be edited by selecting "Edit" from the right menu of the list.

Tips

General Settings

Sets General Settings for job definitions.

ItemSpecificationExplanationNote
Job definition nameRequiredSets the name of the job definition.Any string of up to 64 characters
DescriptionOptionalJob Definition DescriptionAny string of up to 512 characters
Execution timeout timeOptionalJob 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
ParametersOptionalParameters 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.

ItemSpecificationExplanationNote
TypeOptionalSpecifies the type of trigger.
  • Schedule/Cron
Any string of up to 64 characters
TriggerRequiredSet the trigger.
Enter scheduled times with auto-repeat and fixed schedules.
Display time zoneRequiredThe 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:

ItemExplanation
Job DefinitionDisplays the job definition name.
TriggerDisplays the trigger name.
StatusDisplays the enabled/disabled status of the job definition.
Next execution timeDisplays the next scheduled execution time of the job.
If the trigger is not set or disabled, it will not be displayed.
Creation timeDisplays the creation time of the job definition.
Right menuOpen 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 NameExplanationType
BATCH_JOB_IDID of the job to be automatically assignedstring
BATCH_JOB_DEFINITION_NAMEUser-defined job definition namestring
BATCH_JOB_NAMEJob name set by userstring

Built-in Functions

Describes built-in functions that can be used within batch scripts.

Built-in FunctionsDescriptionUsage 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