• Overview
  • Functions
    • Overview
    • action
    • connect
    • count
    • create_issue
    • create_vertex
    • dateprint
    • delete_vertex
    • disconnect
    • eject_issue
    • execute
    • find_timeseries
    • goto
    • html_extract
    • if
    • javascript
    • log
    • query
    • read_attachment
    • read_timeseries
    • read_vertex
    • regex
    • replace
    • sleep
    • split
    • stop_issue
    • suspend
    • suspend_until
    • update_vertex
    • write_attachment
    • write_timeseries
  • Definitions
  • Automation Issue Lifecycle
  • KI Best Practices
  • KI Debugging
Table of Contents
Avoid using if constructs for large algorithms in a single KI. Please see the Logical Branching section for more information.

Definition

if allows conditional execution. It contains a condition to be evaluated first. If the condition is true, the then block gets executed. Otherwise if the condition is false, the optional else block gets executed.

Usage

The if block will check the exit code of a command:

stdout: ExecuteOutput,
exit: Error = execute(
"/some/command/path -with arguments",
host: "_AAE_"
)

if Error then
    log.error("command exited with non-zero exit code")
else
    log("execute returned ${ExecuteOutput}")
end

Example

The following example will check the numerical exit code of a command:

if LOCAL::CODE == "0" then
    persData = "extracted"
    delete(GetPersonData)
else
    persData = "failed"
    log("failed to get data for Person: ${persNo}")
end

You can also use "and" and "or" to consider multiple conditions within a single if block.

if LOCAL::CODE == "0" and LOCAL::Status == "SUCCESS" then
    persData = "extracted"
    delete(GetPersonData)
end