Go to If

Advances or returns to the point where a marker is inserted in the script if a condition is met.

Command availability: IBM RPA SaaS and IBM RPA on premises

Description

Advances or returns to the point where a marker is inserted in the script if a condition is met.

Script syntax

IBM RPA's proprietary script language has a syntax similar to other programming languages. The script syntax defines the command's syntax in the script file. You can work with this syntax in IBM RPA Studio's Script mode.

gotoIf --label(String) --left(Variant) --operator(ConditionalOperators) --right(Variant) [--negate(Boolean)]

Input parameters

The following table displays the list of input parameters available in this command. In the table, you can see the parameter name when working in IBM RPA Studio's Script mode and its Designer mode equivalent label.

Designer mode label Script mode name Required Accepted variable types Description
Label label Required Text Label used to define which point in the script to advance or return to.
Left Operand left Required Any Value used to evaluate the condition.
Operator operator Required ConditionalOperators Rule used to evaluate the condition. For more information, see operator parameter options.
Right operand right Required when Operator is Equal_To, Greater_Than, Greater_Than_Equal_To, Less_Than, Less_Than_Equal_To, Contains, Ends_With, Begins_With, Matches Any Value that is compared to the Left operand to evaluate the condition.
Negate negate Optional Boolean Negates the rule defined in Operator.

operator parameter options

The following values are supported for the Operator expression that evaluates the condition.

  • Begins with
  • Contains
  • Ends with
  • Equal to
  • Greater than
  • Greater than or equal to
  • Is empty
  • Is null
  • Is null or empty
  • Is true
  • Less than
  • Less than or equal to
  • Matches

Example

A label is inserted with an incremented variable. If the variable "counter" is less than 10, the Go to If command returns to the point where the Insert Label command is and increments 1 to the variable as long as the condition is not met. The Log Message command displays "Executed" as long as the condition is true.

defVar --name counter --type Numeric --value 0
label --name IBM
incrementVar --number ${counter}
logMessage --message Executed --type "Info"
gotoIf --label IBM --left "${counter}" --operator "Equal_To" --right 10 --negate 
// Result: Executed
// Executed
// Executed
// Executed
// Executed
// Executed
// Executed
// Executed
// Executed
// Executed