アクションから値を返す

CommandPkg で以下のプロパティを設定し、変数にアクションの出力を保存します。

アクションの戻り値

  • [return_type]

    アクションの戻り値を定義します。通常は、エントリ メソッドの戻り値の型と一致します。

  • [return_required]

    値が true に設定されている場合、戻り値が必要です。

  • [return_label]

    変数値の UI ラベルの説明。

例: sourceString を大文字に変換し、その結果を 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,