从动作返回值
- Updated: 2022/05/19
在 CommandPkg 上设置以下属性,以将动作输出存储在变量中。
动作返回值
-
return_type
定义动作的返回类型。 它通常与入口方法返回类型匹配。
-
return_required
当值设定为 true 后,返回值为必需。
-
return_label
变量值的用户界面标签描述。
示例: 将 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,