# Get the current selections

Get the current selections by using the [GetLayout method](https://help.qlik.com/en-US/sense-developer/May2025/Subsystems/EngineJSONAPI/Content/service-genericobject-getlayout.htm) on a session object in which qSelectionObjectDef is defined.

## Example

[](https://help.qlik.com/en-US/sense-developer/Subsystems/EngineAPI/Content/Sense_EngineAPI/DiscoveringAndAnalysing/MakeSelections/get-current-selections.htm)

#### The goal is to get the current selections in the app.

1. Create a session object.

The client sends:

```
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "CreateSessionObject",
  "handle": 1,
  "params": [
    {
      "qInfo": {
        "qId": "",
        "qType": "SessionLists"
      },
      "qSelectionObjectDef": {}
    }
  ]
}
```

The engine returns:

```
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": {
    "qReturn": {
      "qType": "GenericObject",
      "qHandle": 2
    }
  },
  "change": [
    2
  ]
}
```

The session object is created and has 2 as a handle 2.

2. Get the layout of the session object (handle is 2).

The client sends:

```
{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "GetLayout",
  "handle": 2,
  "params": []
}
```

The engine returns:

```
{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "qLayout": {
      "qInfo": {
        "qId": "SE01",
        "qType": "SessionLists"
      },
      "qMeta": {},
      "qSelectionInfo": {},
      "qSelectionObject": {
        "qBackCount": 0,
        "qForwardCount": 0,
        "qSelections": [
          {
            "qTotal": 6,
            "qField": "Language",
            "qSelectedCount": 1,
            "qSelected": "English",
            "qRangeInfo": [],
            "qSortIndex": 0
          },
          {
            "qTotal": 2,
            "qField": "Temp",
            "qSelectedCount": 1,
            "qSelected": "Celsius",
            "qRangeInfo": [],
            "qSortIndex": 1
          },
          {
            "qTotal": 2,
            "qField": "Rainfall",
            "qSelectedCount": 1,
            "qSelected": "Inches",
            "qRangeInfo": [],
            "qSortIndex": 2
          }
        ]
      }
    }
  }
}
```

Three fields contain selections (defined in qSelections).

3. Create a list object LB01 (qId is LB01). In this example, a non persistent list object is created, with one field named Country (qFieldDefs is Country). The initial data fetch is the first three values of the field Country (qTop is 0, qLeft is 0, qWidth is 1 and qHeight is 3).

The client sends:

```
{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "CreateSessionObject",
  "handle": 1,
  "params": [
    {
      "qInfo": {
        "qId": "LB01",
        "qType": "ListObject"
      },
      "qListObjectDef": {
        "qStateName": "$",
        "qLibraryId": "",
        "qDef": {
          "qFieldDefs": [
            "Country"
          ],
          "qFieldLabels": [
            "Country Label"
          ],
          "qSortCriterias": [
            {
              "qSortByLoadOrder": 1
            }
          ]
        },
        "qInitialDataFetch": [
          {
            "qTop": 0,
            "qHeight": 3,
            "qLeft": 0,
            "qWidth": 1
          }
        ]
      }
    }
  ]
}
```

The engine returns:

{ "jsonrpc": "2.0", "id": 3, "result": { "qReturn": { "qType": "GenericObject", "qHandle": 3 } }, "change": [ 3 ] }

The list object is created and has 3 as a handle.

4. Get the layout of the list object (handle is 3).

The client sends:

{ "jsonrpc": "2.0", "id": 4, "method": "GetLayout", "handle": 3, "params": [] }

The engine returns:

{ "jsonrpc": "2.0", "id": 4, "result": { "qLayout": { "qInfo": { "qId": "LB01", "qType": "ListObject" }, "qMeta": {}, "qSelectionInfo": {}, "qListObject": { "qStateName": "$", "qSize": { "qcx": 1, "qcy": 22 }, "qDimensionInfo": { "qFallbackTitle": "Country Label", "qApprMaxGlyphCount": 14, "qCardinal": 22, "qSortIndicator": "A", "qGroupFallbackTitles": [ "Country Label" ], "qGroupPos": 0, "qStateCounts": { "qLocked": 0, "qSelected": 0, "qOption": 22, "qDeselected": 0, "qAlternative": 0, "qExcluded": 0 }, "qTags": [ "$ascii", "$text" ], "qDimensionType": "D", "qGrouping": "N" }, "qExpressions": [], "qDataPages": [ { "qMatrix": [ [ { "qText": "United States", "qNum": "NaN", "qElemNumber": 0, "qState": "O" } ], [ { "qText": "Denmark", "qNum": "NaN", "qElemNumber": 1, "qState": "O" } ], [ { "qText": "Spain", "qNum": "NaN", "qElemNumber": 2, "qState": "O" } ] ], "qTails": [], "qArea": { "qLeft": 0, "qTop": 0, "qWidth": 1, "qHeight": 3 } } ] } } } }

As defined in the initial data fetch (in Step 3), the first three values of the field Country are displayed.

5. Select United States and Denmark (respectively qValues 0 and 1).

The client sends:

{ "jsonrpc": "2.0", "id": 5, "method": "SelectListObjectValues", "handle": 3, "params": [ "/qListObjectDef", [ 0, 1 ], false ] }

The engine returns:

{ "jsonrpc": "2.0", "id": 5, "result": { "qSuccess": true }, "change": [ 1, 2, 3 ] }

The selections are successful.

6. Get the layout of the session object (handle is 2).

The client sends:

{ "jsonrpc": "2.0", "id": 6, "method": "GetLayout", "handle": 2, "params": [] }

The engine returns:

{ "jsonrpc": "2.0", "id": 6, "result": { "qLayout": { "qInfo": { "qId": "SE01", "qType": "SessionLists" }, "qMeta": {}, "qSelectionInfo": {}, "qSelectionObject": { "qBackCount": 1, "qForwardCount": 0, "qSelections": [ { "qTotal": 22, "qField": "Country", "qSelectedCount": 2, "qSelected": "United States, Denmark", "qRangeInfo": [], "qSortIndex": 3 }, { "qTotal": 6, "qField": "Language", "qSelectedCount": 1, "qSelected": "English", "qRangeInfo": [], "qSortIndex": 0 }, { "qTotal": 2, "qField": "Temp", "qSelectedCount": 1, "qSelected": "Celsius", "qRangeInfo": [], "qSortIndex": 1 }, { "qTotal": 2, "qField": "Rainfall", "qSelectedCount": 1, "qSelected": "Inches", "qRangeInfo": [], "qSortIndex": 2 } ] } } } }

Four fields contain selections. For each selected field is given:

* the name of the field
* the number of selected values
* the names of the selected values
* the total number of values in the field

## Learn more

* [SelectionObject](https://help.qlik.com/en-US/sense-developer/May2025/Subsystems/EngineJSONAPI/Content/generic-object-layouts-SelectionObject.htm)