Skip to main content

Automation wait logic

Business users might come across a use case such as waiting for a specific application to start, information to be displayed, or user interaction. Pega Robot Studio provides a logic that causes an automation to wait until the Created event for particular objects (such as screens, forms, or applications) occur. It also allows pausing an automation for a certain amount of time or waiting for particular events, like clicking the button. 

Pega Robot Studio contains two components that allow waiting until some part of the application is displayed: WaitAll and WaitAny. The components are accessible from the Work Flow category of the Toolbox. Both the WaitAll and WaitAny components have a TimeOut parameter that specifies the amount of time the Wait component allows to elapse to create input components. If the input components do not appear within the specified time, the Timeout event is triggered.

WaitAll and WaitAny components

WaitAll

The WaitAll component triggers an event only if all the objects specified in a group are created. It is typically used when you need to ensure the creation of more than one unlinked elements. 

If the controls are not created in a particular sequence within the Timeout property interval, the WaitAll component triggers the Timeout event.

To add the WaitAll component, open the Toolbox tab, search for WaitAll, and then click and drag the WaitAll component to the design surface. To connect each object to the WaitAll component, select a control from the Palette to add the WaitHandle property to the automation surface. From there, connect the blue data port from the WaitHandle property to the port of the WaitAll component. The WaitHandle is a signal that is turned on when a control is created.

For example, an accountant company collects invoices in the web application and uses a Windows application for booking. The automation needs to wait until the invoice form and accounting application are created to book an invoice. If the controls are not created within the Timeout property interval, an automation displays an error message. 

Screenshot showing automation using WaitAll component with two wait handles for concerning applications.

WaitAny

The WaitAny component triggers an event when any object in a group is created. The component is used to wait when there are multiple possible outcomes. If an object is not created within the Timeout property value, the WaitAny component triggers the Timeout event.

To add the WaitAny component solution, open the Toolbox tab, search for WaitAny, and then click and drag the WaitAny component to the design surface. To connect each control to the WaitAny component, select each control from the Palette and add the WaitHandle property to the automation surface. Connect the blue data port from the WaitHandle property to the port of the WaitAny component.

For example, when logging in to the application, you have two possible outcomes. If the login is successful, you are redirected to the main application window. If your password expired, the password change form is displayed. Using the WaitAny component determines which path has been taken and then chooses the appropriate action. 

Screenshot showing the use of WaitAny component with two possible outcomes.

WaitForEvent

Pega Robot Studio provides a method to wait for events, such as a user interaction with the application interface. 

In the following example, a customer service representative (CSR) must check the account balance, but a customer has more than one opened account. The CSR needs to interact with the application to choose the account with which to proceed. 

An example of WaitForEvent design block

Unlike the Created event, WaitForEvent does not evaluate the control's state when starting to wait. Instead, it listens for the event's next occurrence and waits until the control is created again. 

In the following image, click the + icons to see details about using the WaitForEvent design block to incorporate the user's interaction. 

To add the WaitForEvent function on an event, right-click the event, and then select the Wait for this event option.

Screenshot showing right-click menu with "Wait for this event" option.

Timer

The Timer component generates the events in a regular interval of time. For example, an online retail application is supposed to collect all orders with a 30 minute time interval and send a group of requests for order fulfillment. An automation uses a Timer component to implement this requirement. 

The Timer component is located under the Work Flow section in the Toolbox. 

A Timer component of the Toolbox

To add the timer to your automation, drag and drop the component to the design surface. The component is automatically added to a Local section of the Palette. Define a time interval in a properties window, and use a Start method and Elapsed event to handle a timer. The Elapsed event is triggered regularly in a defined interval. If you want the timer to run only once, set an AutoReset property to false. 

Check your knowledge with the following interaction.


This Topic is available in the following Module:

If you are having problems with your training, please review the Pega Academy Support FAQs.

Did you find this content helpful?

Want to help us improve this content?

We'd prefer it if you saw us at our best.

Pega Academy has detected you are using a browser which may prevent you from experiencing the site as intended. To improve your experience, please update your browser.

Close Deprecation Notice