Skip to Content

Working with Code

Studio allows you to develop automation scenarios in Pure code mode.

To do this, when creating a scenario (or process), select the Code only type (1) and specify the programming language (2): arg1.png

By default, C# is used, but you can choose Python or JavaScript instead. After creating the process, the code editor opens, allowing you to work with the elements: arg1.png

How to add an element to the process

On the Project panel, find the desired component and drag it into the code editor - a sample will be created for its call. arg1.png

In the sections dedicated to describing elements, you can usually find a Pure code subsection - it contains examples of using elements in pure code. See the example for the Get value element: arg1.png

How to call another process inside a process

To call another process, drag the corresponding process file from the Project panel into the code. arg1.png

How to use arguments

The code supports arguments - variables for exchanging data between processes. Working with them is no different from other types of processes. You can also use the GetArgument and SetArgument methods of the global wf variable to work with arguments.

How to create a search pattern

There are buttons in the code editor menu arg1.png - use them to create a search pattern for the control element. If you need to edit the pattern, select it in the code and also use one of these buttons. arg1.png

How to set a breakpoint

Click the Stop button in the code editor menu: arg1.png

A line calling the breakpoint will appear in the code: arg1.png

ℹ️

In Python and JavaScript, the last parameter is responsible for the line number of the breakpoint.

Please note that in Studio version 23.11, a version v2 core has been implemented for the pure code debugger. Its advantages include:

  • Color indicators are now used for breakpoints instead of code (see the figure below).
  • The current values of local function variables are now visible. In core version v1, only the current values of class variables are displayed in the Output panel.
  • It is possible to go to the function code at the breakpoint. arg1.png

You can select the Pure code debugger core in the Studio settings window. By default, version v1 is used. arg1.png

⚠️
  • If you change the core version, be sure to restart Studio.\
  • If you change the core in projects where breakpoints were set in code (v1), remove them and create new ones (v2) to avoid compatibility issues.\
  • You cannot use uninitialized variables with the v2 debugger.

Where to view the current variable value during debugging

Add a breakpoint to the desired element and use the Debug command: arg1.png

In the Project panel, open the context menu and select Closed panels: arg1.png

Click the Output button that appears under the Project panel: arg1.png

Go to the Output panel by clicking the corresponding button at the bottom:

arg1.png

View the state of variables at the moment when code execution is paused. arg1.png

If incorrect data is displayed in the Output panel - for example, from the last debugging in sequence mode - simply click the Refresh button: arg1.png

Starting with Primo RPA Studio version 1.24.6, a Pause button has been added for processes of the Pure code type. This function allows you to interrupt the process execution at the required moment, which increases the accuracy of control.

Limitations

Depending on the selected language, the formatting rules and working with the code will differ. For example, in C#, a special variable __debug will be created, responsible for working with the debugger.

Also, the following limitations exist in the languages:

  • In Python, only variables whose names start with an underscore character are displayed in the Variables panel.
  • JavaScript does not support displaying variables and the Watch panel.
  • The Watch panel only works with visible variables.
Last updated on