Using the Roberty actions by code
Using the Roberty actions by code
Every Roberty action can be used through javascript code. When you are inside the Designer, you can create an action through a Custom Code and use it as in the example below:
const teste = await Modulo.metodo["versão"]({
parametro1: 'valor1',
parametro2: 'valor2',
})
The teste constant receives the value of the instance returned by the class method chosen. This structure is used to create any action through the Roberty api inside the Designer.
The await operator is necessary in most actions since the robot code is executed asynchronously — that is, the execution of an action is awaited before the robot moves on to the next one.
The parameters found between the are the settings that must be passed to the action method. Not every action has parameters in the JSON "" format or needs a parameter to be passed; several parameters are optional. These situations can be found in the documentation of each action, available in the left sidebar of this page.
The example below shows how to access the return the teste constant started to receive after the method was called.
const valor1 = teste.retorno1
const valor2 = teste.retorno2
When you create a custom code for an action, you can use the return operator so the custom code receives the return of the action. As shown in the example below:
return await Módulo.método["versão"]({
parametro1: 'valor1',
parametro2: 'valor2',
})