Lea y revise la documentación de Automation Anywhere

Automation Anywhere Automation 360

Cerrar contenidos


Abrir contenidos

Configure shared session attributes using Package SDK

  • Actualizado: 2021/05/12

    Configure shared session attributes using Package SDK

    Create new Package SDK files and modify existing files to configure a variable, command, and the attribute type to share details between TaskBots.

    Add session type to the package template

    Open the package template file located at <latest package sdk zip file>\src\main\resources and add sessionType: label and an optional description.

      "name": "A2019DemoPackage",
      "label": "[[label]]",
      "description": "[[description]]",
      "sessionType" : {
        	"label" : "testdemo",
        	"description" : "sharedSessionDemo"
      "group": "",
      "artifactName": "",
      "packageVersion": "",
      "codeVersion": "",
      "author": "",
      "commands": []

    Create a new custom variable

    Create a new DemoForSession file and place it at the following location: <latest package sdk zip file>/src/main/java/com/automationanywhere/botcommand/samples/commands/basic

    Using the file, create the custom variable (Dto class) to share details between TaskBots and implement the CloseableSessionObject variable.

    package com.automationanywhere.botcommand.samples.commands.basic;
    import com.automationanywhere.toolchain.runtime.session.CloseableSessionObject;
    import java.io.IOException;
    public class DemoForSession implements CloseableSessionObject
        public void setClose(boolean close) {
            this.close = close;
        boolean close=false;
        public String getDemo() {
            return demo;
        public void setDemo(String demo) {
            this.demo = demo;
        public DemoForSession(String demo){
        String demo;
        public boolean isClosed() {
            return close;
        public void close() throws IOException {

    Create a new command

    Using the DemoForSession file, develop a command that retrieves the SharedSessionDemoUpperCaseParent from the public sessionMap and assigns it to sessionMap object.

    package com.automationanywhere.botcommand.samples.commands.basic;
    import com.automationanywhere.botcommand.data.Value;
    import com.automationanywhere.botcommand.data.impl.SessionValue;
    import com.automationanywhere.botcommand.data.impl.StringValue;
    import com.automationanywhere.commandsdk.annotations.*;
    import com.automationanywhere.commandsdk.annotations.rules.NotEmpty;
    import java.util.Map;
    import static com.automationanywhere.commandsdk.model.AttributeType.TEXT;
    import static com.automationanywhere.commandsdk.model.DataType.SESSION;
    import static com.automationanywhere.commandsdk.model.DataType.STRING;
    @CommandPkg(return_label = "SharedSessionDemoUpperCaseParent", node_label = "SharedSessionDemoUpperCaseParent", label = "SharedSessionDemoUpperCaseParent", description = "SharedSessionDemoUpperCaseParent", name = "SharedSessionDemoUpperCaseParent", return_type = SESSION, return_required = true)
    public class SharedSessionDemoUpperCaseParent {
        public void setSessionMap(Map<String, Object> sessionMap) {
            this.sessionMap = sessionMap;
        private Map<String, Object> sessionMap;
        public Value<?> execute(@Idx(index = "1", type = TEXT)
                                @Pkg(label = "SetSession", description = "SetSession", default_value = "Default", default_value_type = STRING)
                                        String session) {
            Object sessionObject = sessionMap.get(session);
            System.out.println("sessionObject: "+sessionObject);
            SessionValue sessionValue=new SessionValue((DemoForSession) sessionObject);
            return sessionValue;

    Configure the attributeType. Session

    In the SharedSessionDemoUpperCaseChild file, configure the attributeType.Session for the sharedSession parameter.

    @Idx(index = "3", type = AttributeType.SESSION)
    @Pkg(label = "sharedSession", description = "sharedSession", 
          default_value = "Default", default_value_type = DataType.SESSION)
          SharedSessionDemoUpperCaseChild session
    Enviar comentarios