# Clone a dimension

Clone a dimension by using the [CloneDimension method](https://help.qlik.com/en-US/sense-developer/November2024/Subsystems/EngineJSONAPI/Content/service-doc-clonedimension.htm).

## Example

[](https://help.qlik.com/en-US/sense-developer/Subsystems/EngineAPI/Content/Sense_EngineAPI/WorkingWithAppsAndVisualizations/CreateVisualizations/clone-dimension.htm)

#### The goal is to clone a dimension.

The handle of the app is 1.

1. Create an engine session list in order to list the dimensions in the app (qDimensionListDef).

The client sends:

```
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "CreateObject",
  "handle": 1,
  "params": [
    {
      "qInfo": {
        "qId": "SE01",
        "qType": "SessionLists"
      },
      "qAppObjectListDef": {
        "qType": "sheet",
        "qData": {
          "id": "/qInfo/qId"
        }
      },
      "qDimensionListDef": {
        "qType": "Dimension",
        "qData": {}
      },
      "qMeasureListDef": {
        "qType": "Measure",
        "qData": {}
      }
    }
  ]
}
```

The engine returns:

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

The engine session list SE01 is created and has 2 as a handle.

2. Create a dimension in the app with the identifier Dimension01.

The client sends:

```
{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "CreateDimension",
  "handle": 1,
  "params": [
    {
      "qInfo": {
        "qId": "Dimension01",
        "qType": "Dimension"
      },
      "qDim": {
        "qGrouping": "N",
        "qFieldDefs": [
          "Country"
        ],
        "qFieldLabels": [
          "Country library label"
        ]
      }
    }
  ]
}
```

The engine returns:

```
{
  "jsonrpc": "2.0",
  "id": 2,
  "result": {
    "qReturn": {
      "qType": "GenericDimension",
      "qHandle": 3
    },
    "qInfo": {
      "qId": "Dimension01",
      "qType": "Dimension"
    }
  },
  "change": [
    3
  ]
}
```

The dimension Dimension01 is created and has 3 as a handle.

3. Clone the dimension Dimension01.

The client sends:

```
{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "CloneDimension",
  "handle": 1,
  "params": [
    "Dimension01"
  ]
}
```

The engine returns:

{ "jsonrpc": "2.0", "id": 3, "result": { "qCloneId": "342af77a-7d70-4ea6-bcc4-885a8f91acf9" } }

The clone is created. The identifier (set by the engine) of the clone is 342af77a-7d70-4ea6-bcc4-885a8f91acf9.

4. Get the handle of the clone. The identifier is 342af77a-7d70-4ea6-bcc4-885a8f91acf9.

The client sends:

{ "jsonrpc": "2.0", "id": 4, "method": "GetDimension", "handle": 1, "params": [ "342af77a-7d70-4ea6-bcc4-885a8f91acf9" ] }

The engine returns:

{ "jsonrpc": "2.0", "id": 4, "result": { "qReturn": { "qType": "GenericDimension", "qHandle": 4 } } }

The handle of the clone is 4.

5. Get the properties of the clone.

The client sends:

{ "jsonrpc": "2.0", "id": 5, "method": "GetProperties", "handle": 4, "params": [] }

The engine returns:

{ "jsonrpc": "2.0", "id": 5, "result": { "qProp": { "qInfo": { "qId": "342af77a-7d70-4ea6-bcc4-885a8f91acf9", "qType": "Dimension" }, "qDim": { "qGrouping": "N", "qFieldDefs": [ "Country" ], "qFieldLabels": [ "Country library label" ] }, "qMetaDef": {} } } }

The clone is identical to the original dimension.

6. Check that the clone is added to the session list. The handle of the request is 2 because the handle of the session list 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" }, "qSelectionInfo": {}, "qAppObjectList": { "qItems": [] }, "qDimensionList": { "qItems": [ { "qInfo": { "qId": "Dimension01", "qType": "Dimension" }, "qData": {} }, { "qInfo": { "qId": "342af77a-7d70-4ea6-bcc4-885a8f91acf9", "qType": "Dimension" }, "qData": {} } ] }, "qMeasureList": { "qItems": [] } } } }

The session list contains the dimension Dimension01 and the clone 342af77a-7d70-4ea6-bcc4-885a8f91acf9.