Return a value from an action

Set the following properties on CommandPkg to store the action output in a variable.

Action return values

  • return_type

    Defines the return type of the action. It usually matches the entry method return type.

  • return_required

    When the value is set to true the return value is required.

  • return_label

    A description of the UI label for the variable value.

Example: Convert a sourceString to uppercase and assign the result to returnTo

//BotCommand makes a class eligible for being considered as an action.
@BotCommand

//CommandPks adds required information to be displayable on the UI.
@CommandPkg(
		//Unique name inside a package and label to display.
		name = "uppercase", label = "[[Uppercase.label]]",  
		node_label = "[[Uppercase.node_label]]",  description = "[[Uppercase.description]]", icon = "pkg.svg", 
		
		//Return type information. return_type ensures only the right kind of variable is provided on the UI. 
		return_label = "[[Uppercase.return_label]]", return_type = STRING, return_required = true)
public class Uppercase {
	
	//Messages read from a fully qualified property file name and provides i18n capability.
	private static final Messages MESSAGES = MessagesFactory
			.getMessages("com.automationanywhere.botcommand.samples.messages");

	//Identify the entry point for the action. Returns a Value <String> because the return type is String. 
	@Execute
	public Value<String> action(
			//Idx 1 would be displayed first, with a text box for entering the value.
			@Idx(index = "1", type = TEXT) 
			//UI labels.
			@Pkg(label = "[[Uppercase.sourceString.label]]") 
			//Ensure that a validation error is thrown when the value is null.
			@NotEmpty 
			String sourceString,