Read and Review Automation Anywhere Documentation

Automation 360

Close Contents

Contents

Open Contents

Create custom variables using Package SDK

  • Updated: 4/23/2021
    • Automation 360 v.x
    • Explore
    • RPA Workspace

Create custom variables using Package SDK

When using Automation 360, you can create custom variables using the SDK package.

Using custom variables

Use Automation 360 to create a custom variable. This is a system variable and is used as other bot variables, except it is read-only and the value is calculated instead of being assigned.

Required annotations

For creating a variable, the following annotations are required:

Annotation Usage
BotCommand Use the BotCommand annotation with the variable as commandType. This ensures that the plain old Java object (POJO) is suitable for creating an Automation 360 variable.
CommandPkg These values are used when creating a package. Provide a name, label, and description to the annotation.
Idx Annotate all the parameters and member variables that are required and help with the validation check. Alternatively they might be displayed in the interface for the input. Provide the index (Idx) and the type.
Pkg Annotate all the parameters and member variables that will be shown in the interface. This annotation will be ignored if it is not accompanied by the Idx.
VariableExecute The method that has to be called for returning the variable value. This method does not accept any input parameters. Sessions and GlobalSessionContext are available though setter injection.

Use case example

The following use case shows how to return the current time for the system default zone.

  1. Create the POJO class with the business logic:
    public class Now {
    	
    	public DateTimeValue now() {
    		Instant instant = Instant.now();
    		ZonedDateTime now = instant.atZone(ZoneId.systemDefault());
    		return new DateTimeValue(now);
    	}
    
    }
  2. Annotate the POJO class to enable it for the Automation 360 variable and to create the package:
    @BotCommand(commandType = BotCommand.CommandType.Variable)
    @CommandPkg(description = "The current datetime at system default zone.", name = "Now", label = "", variable_return_type = DataType.DATETIME)
    public class Now {
    	
    	public DateTimeValue now() {
    		Instant instant = Instant.now();
    		ZonedDateTime now = instant.atZone(ZoneId.systemDefault());
    		return new DateTimeValue(now);
    	}
    
    }
  3. Annotate the now method to denote it to be the execute method.
    @VariableExecute
    	public DateTimeValue now() {
    		Instant instant = Instant.now();
    		ZonedDateTime now = instant.atZone(ZoneId.systemDefault());
    		return new DateTimeValue(now);
    	}

    Every variable must have one test VariableExecute method.

Send Feedback