{
  "eventsAndFunctions": [
    {
      "algorithm": {
        "parameters": [],
        "statements": [
          {
            "command": "Refresh",
            "widgetName": "InteractionsGrid"
          },
          {
            "command": "Execute",
            "expression": "setProcessItem()"
          }
        ],
        "typeReturn": "any",
        "variables": []
      },
      "name": "main_init"
    },
    {
      "algorithm": {
        "parameters": [
          {
            "name": "args",
            "type": "ArgsLoadRecords"
          }
        ],
        "statements": [
          {
            "command": "Return",
            "expression": "getInteractions(^args)"
          }
        ],
        "typeReturn": "any",
        "variables": []
      },
      "name": "InteractionsGrid_loadRecords"
    },
    {
      "algorithm": {
        "parameters": [],
        "statements": [
          {
            "command": "ReadModel",
            "modelVariableName": "process",
            "variableName": "process"
          },
          {
            "children": [
              {
                "command": "Throw",
                "errorName": "Error",
                "expressionData": "\"[[ErrorFillFormTitle]]\"",
                "expressionInnerError": "\"[[ErrorFillFormMsg]]\""
              }
            ],
            "command": "If",
            "expression": "IsNull(^process)"
          },
          {
            "children": [
              {
                "command": "Execute",
                "expression": "editProcess(^process)"
              }
            ],
            "command": "If",
            "expression": "IsNotNull(^process) && IsNotNull(^process.processId)"
          },
          {
            "children": [
              {
                "command": "Execute",
                "expression": "createProcess(^process)"
              }
            ],
            "command": "Else"
          }
        ],
        "typeReturn": "any",
        "variables": [
          {
            "name": "process",
            "type": "ProcessBff.RspdProcess"
          }
        ]
      },
      "name": "main_submit"
    },
    {
      "algorithm": {
        "parameters": [
          {
            "name": "recordData",
            "type": "any"
          }
        ],
        "statements": [
          {
            "command": "Return",
            "expression": "{ text:\"<img src='./icons/platform.svg'>\"}"
          }
        ],
        "typeReturn": "obj(icon:string, text:string)",
        "variables": []
      },
      "name": "InteractionsGrid_renderColumn_icon"
    },
    {
      "algorithm": {
        "parameters": [
          {
            "name": "args",
            "type": "ArgsLoadRecords"
          }
        ],
        "statements": [
          {
            "command": "ReadModel",
            "modelVariableName": "listInteractions",
            "variableName": "listInteractions"
          },
          {
            "children": [
              {
                "command": "Set",
                "expression": "ExtInteractionEngine.ListSpecs({tenantId:1, name:^args.searchText, limit:^args.limit, offset:^args.offset})",
                "variableName": "listInteractions"
              },
              {
                "command": "Set",
                "expression": "FindAll(^listInteractions, businessType == \"Interaction\" && status == \"Design\")",
                "variableName": "listInteractions"
              },
              {
                "command": "WriteModel",
                "expression": "^listInteractions",
                "modelVariableName": "listInteractions"
              }
            ],
            "command": "If",
            "expression": "IsNull(^listInteractions)"
          },
          {
            "children": [
              {
                "command": "Set",
                "expression": "FindAll(^listInteractions, Contains(ToUpper(name), ToUpper(^args.searchText)))",
                "variableName": "listInteractions"
              }
            ],
            "command": "If",
            "expression": "IsNotNull(^args) && IsNotNull(^args.searchText)"
          },
          {
            "children": [
              {
                "command": "Set",
                "expression": "SortDescending(^listInteractions, code)",
                "variableName": "listInteractions"
              }
            ],
            "command": "If",
            "expression": "Count(^listInteractions) > 0"
          },
          {
            "command": "Return",
            "expression": "^listInteractions"
          }
        ],
        "typeReturn": "list(ExtInteractionEngine.Specification)",
        "variables": [
          {
            "name": "listInteractions",
            "type": "list(ExtInteractionEngine.Specification)"
          }
        ]
      },
      "name": "getInteractions"
    },
    {
      "algorithm": {
        "parameters": [
          {
            "name": "process",
            "type": "ProcessBff.RspdProcess"
          }
        ],
        "statements": [
          {
            "command": "GetSelecteds",
            "variableName": "listInteractions",
            "widgetName": "InteractionsGrid"
          },
          {
            "children": [
              {
                "command": "Throw",
                "errorName": "Error",
                "expressionData": "\"[[ErrorFillFormTitle]]\"",
                "expressionInnerError": "\"[[ErrorFillFormMsg]]\""
              }
            ],
            "command": "If",
            "expression": "Count(^listInteractions) == 0"
          },
          {
            "command": "Set",
            "expression": "Now()",
            "variableName": "process.creationDate"
          },
          {
            "command": "Set",
            "expression": "Now()",
            "variableName": "process.lastUpdate"
          },
          {
            "command": "Set",
            "expression": "getDisabled()",
            "variableName": "process.disabled"
          },
          {
            "command": "Set",
            "expression": "ProcessBff.CreateRspdProcess(^process)",
            "variableName": "process"
          },
          {
            "children": [
              {
                "command": "Execute",
                "expression": "ProcessBff.CreateRspdProcessItem(\n {\n\tprocessId:^process.processId, \n    name:^interaction.name,\n    entity:\"Interaction\",\n    disabled: false\n }\n)"
              }
            ],
            "command": "ForEach",
            "expressionList": "listInteractions",
            "variableNameItem": "interaction"
          }
        ],
        "typeReturn": "any",
        "variables": [
          {
            "name": "listInteractions",
            "type": "list(ExtInteractionEngine.Specification)"
          },
          {
            "name": "interaction",
            "type": "ExtInteractionEngine.Specification"
          }
        ]
      },
      "name": "createProcess"
    },
    {
      "algorithm": {
        "parameters": [
          {
            "name": "process",
            "type": "ProcessBff.RspdProcess"
          }
        ],
        "statements": [
          {
            "command": "Set",
            "expression": "Now()",
            "variableName": "process.lastUpdate"
          },
          {
            "command": "Execute",
            "expression": "ProcessBff.UpdateRspdProcess(^process)"
          }
        ],
        "typeReturn": "any",
        "variables": []
      },
      "name": "editProcess"
    },
    {
      "algorithm": {
        "parameters": [],
        "statements": [
          {
            "command": "GetValue",
            "variableName": "enable",
            "widgetName": "cbEnable"
          },
          {
            "children": [
              {
                "command": "Return",
                "expression": "false"
              }
            ],
            "command": "If",
            "expression": "^enable"
          },
          {
            "children": [
              {
                "command": "Return",
                "expression": "true"
              }
            ],
            "command": "Else"
          }
        ],
        "typeReturn": "any",
        "variables": [
          {
            "name": "enable",
            "type": "boolean"
          }
        ]
      },
      "name": "getDisabled"
    },
    {
      "algorithm": {
        "parameters": [],
        "statements": [
          {
            "command": "ReadModel",
            "modelVariableName": "process",
            "variableName": "process"
          },
          {
            "children": [
              {
                "command": "Disable",
                "widgetName": "txtCode"
              },
              {
                "command": "Set",
                "expression": "ProcessBff.ListRspdProcessItems({processId: ^process.processId})",
                "variableName": "listProcessItem"
              }
            ],
            "command": "If",
            "expression": "IsNotNull(^process) && IsNotNull(^process.processId)"
          }
        ],
        "typeReturn": "any",
        "variables": [
          {
            "name": "process",
            "type": "ProcessBff.RspdProcess"
          },
          {
            "name": "listProcessItem",
            "type": "list(ProcessBff.RspdProcessItem)"
          }
        ]
      },
      "name": "setProcessItem"
    }
  ],
  "model": [
    {
      "name": "process",
      "required": false,
      "type": "ProcessBff.RspdProcess"
    },
    {
      "name": "listInteractions",
      "required": false,
      "type": "list(ExtInteractionEngine.Specification)"
    }
  ],
  "root": {
    "children": [
      {
        "children": [
          {
            "binding": "process.code",
            "label": "[[Code]]",
            "last": true,
            "mandatory": true,
            "name": "txtCode",
            "size": 2,
            "widget": "TextBox"
          },
          {
            "binding": "process.name",
            "label": "[[Name]]",
            "last": true,
            "mandatory": true,
            "name": "txtName",
            "size": 2,
            "widget": "TextBox"
          },
          {
            "binding": "process.positionId",
            "label": "[[Position]]",
            "last": true,
            "mandatory": true,
            "name": "txtPosition",
            "size": 2,
            "widget": "NumericBox"
          },
          {
            "binding": "process.disabled",
            "label": "[[Enable]]",
            "last": true,
            "name": "cbEnable",
            "size": 2,
            "widget": "CheckBox"
          }
        ],
        "layout": "form"
      },
      {
        "children": [
          {
            "columns": [
              {
                "align": "left",
                "bindText": "icon",
                "key": "icon"
              },
              {
                "align": "left",
                "bindText": "name",
                "key": "name"
              },
              {
                "align": "left"
              }
            ],
            "cssClass": "blz-area-default blz-grid-cell-image",
            "hideHeaders": true,
            "multiselection": true,
            "name": "InteractionsGrid",
            "pageSize": 10,
            "widget": "Grid",
            "withPaging": true,
            "withSearch": true
          }
        ],
        "layout": "fit"
      }
    ],
    "layout": "responsive"
  },
  "routing": null,
  "unused": []
}