Skip to main content

Application of keys

After enabling the UseKeys property for an interrogated control, Pega Robot Studio generates and assigns a key whenever a context exists for cloneable controls. Here, the term context defines an instance of a control for which multiple instances (clones) occur. In the following image, the CRMChild control, shown with two instances as referenced in the Palette, is the context.

Application key with palette

Application of keys

To assist the developer when a cloneable control requires a key, Pega Robot Studio uses rules to determine the creation of keys and the setting of keys for contextual objects within an automation. Pega Robot Studio employs the following rule logic when determining to apply a key:

  • An event that creates the instance sets the context.
  • An event from No Context to a Context requires a key assignment.
  • An event from Context to Child Context requires a key assignment.
  • An event from Context to Parent Context does not require a key assignment.
  • Logic within the same context does not require a key assignment.

Pega Robot Studio assists you in applying rules when developing automations. Automation links enable the rules to function. You must connect the automation links between the design blocks so that Pega Robot Studio can apply the key rules. If the automation requires a key, the design block updates and displays a key option with a data value input for configuration. You may have different values to determine a key, such as Active, Key, None, or Query, depending on the object requiring the key assignment. 

In a call center, the agent can access and work on several accounts at the same time. The agent employs a custom user interface that allows the agent to easily switch between the accounts by selecting the account in the MaincmbGetAcct drop-down list. To ensure the application and user interface update with the correct customer account information, the developer defines the custom Key for each account window as the customer's account number. In the following image, when the agent changes the value in the MaincmbGetAcct, the automation checked to see if the associated account window is active. To determine the correct window to activate, the automation uses the selected text of the MaincmbGetAcct as the key parameter of the account window. If the account window is not active, then activate it; otherwise, do nothing. 

Screenshot showing automation that uses keys to distinguish account windows.

Because the key property is in the first CRMChild automation reference, it is unnecessary in the second automation reference because the logic within the same context does not require a key assignment. 

Key exceptions

As with automation development, a developer must consider if the automation logic needs to shift focus using a different key and require an override or how to handle an exception in the event a key is not found.

Override Key

Once the key is set on the first instance of a context, the application rules state that subsequent or downstream objects do not require a key assignment. However, the automation logic might require a reference to a control from another instance.

By right-clicking on the control’s design block, a context menu is displayed that provides an option to override the upstream key assignment. The design block then provides the key parameter to select either Active, Key (and input value), or None.

Depending on the control type, the override options might exist for all current automation usages of the control, usages of the control’s property, or the main cloneable control creating the context.  In the following image, the main cloneable context is For CRMchild.

Screenshot showing context menu option to override keys for design block.

You can also reset an override by right-clicking and selecting Use Upstream Key.

Handle KeyNotFoundException

On a control’s design block in an automation that assigns a key, logic is available to automate if a key value is not found. To programmatically ensure that the automation logic handles the exception correctly, right-click on the design block with the key assignment and select Handle KeyNotFoundException. The design block updates with a new executable output to manage the automation flow for this key exception.

Screenshot showing popup menu option to handle key exception.

You can also remove the key exception by right-clicking the design block and selecting Do not handle KeyNotFoundException.

Screenshot showing popup menu option to revert handling keys exception.

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