SDAPI Variables, Objects and Object Members 2.0

The Script Debugger API (SDAPI) enables you to interact with halted script threads. When a script thread is halted, you can fetch the list of objects in the context of a script thread and call stack frame. You can also fetch objects inside an object.

To access objects and object members, you use the variables and members actions and you specify a thread identifier and call stack frame index. When requesting members, you can optionally include the object_path query parameter. If you do not use the object_path query parameter, the Script Debugger will return all objects in the context of the specified thread and frame index.

When you specify an object_path query parameter, the value of the parameter is a dot-delimited string representing a path. For exampole, if the query parameter is basket the Script Debugger returns the members of the basket object. If the query parameter is basket.productLineItems, the Script Debugger returns all members of the productLineItems member of the basket object.

The response from the members action is a collection of JSON objects containing four properties:
  • name: the name of the object.
  • parent: the parent of the object.
  • type: the type of the object.
  • value: the value of the object. The value is obtained by calling toString() on the object.
When you an object represents a collection, the name attribute is an index representation of the member inside the collection. For example, "name":"[0]" represents the first element in the collection.

By default, the Script Debugger will return up to 200 objects for the members action and the result set starts with element 200. If the object path has more than 200 elements, you can use the start and count query paramters to control the returned objects.

When requesting variables, the response is a collection of JSON objects containing four properties:
  • name: the name of the object.
  • parent: the parent of the object.
  • type: the type of the object.
  • value: the value of the object. The value is obtained by calling toString() on the object.
  • scope: the scope of the variable, where the value is one of local, closure or global.

In the vast majority of cases, you do not want to interact with a “running” script thread, because there is no guarantee that the thread will be alive when your request is processed.

Examples

Example 1: Get all object members (no query paramter)


REQUEST:
GET /s/-/dw/debugger/v1_0/threads/1/frames/0/members

RESPONSE:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "object_members":
  [
    {
      "name":"args",
      "parent":"",
      "type":"dw.system.PipelineDictionary",
      "value":"[PipelineDictionary id=385366343]"
    },
    {
      "name":"arguments",
      "parent":"",
      "type":"org.mozilla.javascript.Arguments",
      "value":"[email protected]"
    },
    {
      "name":"basket",
      "parent":"",
      "type":"dw.order.Basket",
      "value":"[Basket uuid=bcqpfaOacb6QIaaado1BaeQDFh]"
    }
  ]
}
   

Example 2: Get the members of the productLineItems collection in the basket object


REQUEST:
GET /s/-/dw/debugger/v1_0/threads/1/frames/0members?object_path=basket.productLineItems

RESPONSE:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "object_members":
  [
    {
      "name":"[0]",
      "parent":"basket",
      "type":"dw.order.ProductLineItem",
      "value":"[ProductLineItem uuid=bcDfLaOacbNVMaaadoDBceQDFh]"
    },
    {
      "name":"[1]",
      "parent":"basket",
      "type":"dw.order.ProductLineItem",
      "value":"[ProductLineItem uuid=bcLNbaOacbhiUaaadokBgeQDFh]"
    }
  ]
}
   

Example 3: Get the members of an element inside the productLineItems collection


REQUEST:
GET /s/-/dw/debugger/v1_0/threads/1/frames/0/members?object_path=basket.productLineItems.%5B1%5D

RESPONSE:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "object_members":
  [
    {
      "name":"adjustedGrossPrice",
      "parent":"productLineItems",
      "type":"dw.value.Money",
      "value":"N/A"
    },
    {
      "name":"adjustedNetPrice",
      "parent":"productLineItems",
      "type":"dw.value.Money",
      "value":"N/A"
    }
    
    ...
    
  ]
}
   

Example 4: Get the members of a object using start and count


REQUEST:
GET /s/-/dw/debugger/v1_0/threads/1/frames/0/members?object_path=basket.productLineItems.%5B1%5D&start=50&count=10

RESPONSE:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
  "_v":"2.0",
  "object_members":
  [
    {
      "name":"optionModel",
      "parent":"productLineItems",
      "type":"String",
      "value":"null"
    },
    {
      "name":"optionProductLineItem",
      "parent":"productLineItems",
      "type":"String",
      "value":"false"
    },
    {
      "name":"optionProductLineItems",
      "parent":"productLineItems",
      "type":"dw.util.Collection",
      "value":"[Collection id=865935255]"
    },
    {
      "name":"optionValueID",
      "parent":"productLineItems",
      "type":"String",
      "value":"null"
    },
    {
      "name":"orderItem",
      "parent":"productLineItems",
      "type":"String",
      "value":"null"
    },
    {
      "name":"parent",
      "parent":"productLineItems",
      "type":"String",
      "value":"null"
    },
    {
      "name":"position",
      "parent":"productLineItems",
      "type":"String",
      "value":"2"
    },
    {
      "name":"price",
      "parent":"productLineItems",
      "type":"dw.value.Money",
      "value":"N/A"
    },
    {
      "name":"priceAdjustments",
      "parent":"productLineItems",
      "type":"dw.util.Collection",
      "value":"[Collection id=1994121392]"
    },
    {
      "name":"priceValue",
      "parent":"productLineItems",
      "type":"String",
      "value":"null"
    }
  ]
}
   

Example 5: Get the variables start and count


REQUEST:
GET /s/-/dw/debugger/v1_0/threads/1/frames/0/variables

RESPONSE:
HTTP/1.1 200 OK
Content-Type: application/json;charset=UTF-8
{
    "_v": "2.0",
    "count": 14,
    "object_members": [
        {
            "name": "arguments",
            "parent": "",
            "scope": "local",
            "type": "Object",
            "value": "[object Arguments]"
        },
        {
            "name": "arguments",
            "parent": "",
            "scope": "closure",
            "type": "Object",
            "value": "[object Arguments]"
        },
        {
            "name": "requiredFunction",
            "parent": "",
            "scope": "global",
            "type": "Function",
            "value": "\nfunction requiredFunction() {\n    var dwUtil = require(\"dw/util\");\n    var CustomerMgr = require(\"dw/customer/CustomerMgr\");\n    return true;\n}\n"
        }
    ],
    "start": 0,
    "total": 4
}
   
X Privacy Update: We use cookies to make interactions with our websites and services easy and meaningful, to better understand how they are used and to tailor advertising. By continuing to use this site you are giving us your consent to do this.