Skip to content

How do I transfer the execution control from one block of code to another block by a label when the specific condition is met

This example demonstrates executing a specific block of code by transferring the execution control (i.e., skipping in between steps) only when a condition is met using "gotoIf" and "label" commands.

In the solution shown below, you will see that, the "select" command for selecting an option for "Does Employer offer Health Insurance" dropdown is skipped in HICC based on the environment using "gotoIf" command and the execution control is transfered to "label" command.

Note: You can use store or storeXXX command to define the value (string or boolean) of the variable. The notation to reuse the value of the variable in Worksoft SaaS is ${<Variable Name>}.

Solution:

# Command Target Value
Define the condition to skip the "Does Employer offer Health Insurance" dropdown if the environment is Production
1 gotoIf "${<Variable Name>}"=="Production" Skip_Employer_Offering_Insurance_Selection 
Select an option from Does Employer offer Health Insurance dropdown
2 select
id="dpl_employerInsuranceDropdown"
 label=Yes
Define Label
3 labelSkip_Employer_Offering_Insurance_Selection 
Click on Calculate Button
4 clickid="btn_calculateControls"

Tips, Tricks, Gotchas & Best Practices:  

  • The label can also be specified in the same script or multiple scripts.
  • It is mandatory to have the "gotoIf" command before "label" command.
  • As a best practice, it is always advisable to define the variable names without any spaces and if you want to differentiate the words, use underscore or hyphen.

Feedback and Knowledge Base