Skip to main content

Creating an instance of an object

When working with automations containing complex data types, developers need to create an object that will adequately carry data. To do so, they need to find the constructor that best suits the data to be used. Pega Robot Studio provides two ways to create a new instance of a data type: Create Instance and Add Constructor

When you create an instance from a data port the system makes a copy of the original object's type. You use the Create Instance feature if you already have a design block using the data type that you need in your automation. In the design block, on the output data port, right-click and then select Create Instance

Screenshot showing the Create Instance menu option after right-clicking the data port.

After you select Create Instance, the Create design block is added to the automation surface. By changing the name of the design block, you change the variable's name. The newly created object is added to the Local section of the Palette. To use the instance, drag it to the automation surface to display the Select Action dialog. 

For example, a banking company provides an automation that allows customers to add a co-owner to their bank account. The developer uses the Create Instance feature to create a table that holds the data of the co-owner. Creating the table also creates a new Lookup Table, for which the developer must configure the data columns separately.

Screenshot showing the usage of a created instance in an automation.

Add Constructor

When you need to add a complex type to your automation and don't have a design block of the same type to create an instance from, use the Add Constructor method from the Variables section of the Toolbox by dragging the method to the automation surface, and then picking the type of variable you need to use in your automation.

Add Constructor

Similarly to Add Instance, using the Add Constructor method will add the Create design block on the automation surface and add a variable of the requested type to the Locals section of the Palette. 

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