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.
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 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.
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 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.
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 section of the Palette.
Check your knowledge with the following interaction: