'svcscript' capability for WebSocket Token API

Table of Contents

Overview

Start the service script with passing the start parameters and specifying the execution timeout. The response is received after the script is completed. In case of successful completion, the response contains an object with the values of all local variables.

Script execution and waiting for a response can be interrupted by sending an abort_svcscript request with the same qid value as the original request start_svcscript. In this case, there is an immediate response to the request named abort_svcscript_result.

If a parameter or startup error occurs, the response message is returned immediately. If the responsible microservices are unavailable, the timeout before sending an unsuccessful response can be up to 5 seconds.

You can specify the parameters startparam1, startparam2, …​, startparam20. The start parameters are passed to the script and are available in expressions through the function startparam(N). The first start parameter is available in the Start component to be saved to a variable.

You can set the timeout parameter in milliseconds (default 10000). When the timeout expires, the response wait is interrupted, the script is also interrupted after the next component.

If you need to execute scripts asynchronously, just send requests with unique qid and don’t expect responses.

Request example
[
  "start_svcscript",
  {
    "qid": 123,
    "code": "test_script",
    "startparam1": "abc",
    "startparam2": "def",
    "startparam5": "{\":a\":1}",
    "startparam12": "[{\"a\":\"123\"}\r\n,{\"a\":\"456\"}]",
    "timeout": 5000
  }
]
Example of a response after script completion
[
  "start_svcscript_result",
  {
    "qid": 123,
    "result": "ok",
    "data": {
      "variables": {
        "body": "[{\"a\":1,\"b\":\"111\"},\n{\"a\":2,\"b\":\"222\"},\n{\"a\":1,\"b\":\"333\"},\n{\"b\":\"444\"},\n{}]",
        "code": 36,
        "err": "",
        "path": ":SYNC/common/1.txt",
        "text": "hello"
      }
    }
  }
]
An example of a response after a cutoff.
[
  "abort_svcscript",
  {
    "qid": 123,
    "result": "ok"
  }
]

Parameters:

  • code - service script code in the domain.

  • startparamN - parameter passed to the script.

  • timeout - script execution timeout in milliseconds.

  • result - result code.

  • data - object with details of the result.

  • variables - object with the values of all local scenario variables.