1. The first step, in this example, is to create a list object with one field Country (qFieldDefs is Country). The identifier of the list object is ListObject01. To the field Country will be added in a later step the property qOneAndOnlyOne .
The client sends:
{
"jsonrpc": "2.0",
"id": 1,
"method": "CreateSessionObject",
"handle": 1,
"params": [
{
"qInfo": {
"qId": "ListObject01",
"qType": "ListObject"
},
"qListObjectDef": {
"qStateName": "$",
"qLibraryId": "",
"qDef": {
"qFieldDefs": [
"Country"
],
"qFieldLabels": [
"Country Label"
],
"qSortCriterias": [
{
"qSortByLoadOrder": 1
}
]
},
"qInitialDataFetch": [
{
"qTop": 0,
"qHeight": 1,
"qLeft": 0,
"qWidth": 1
}
]
}
}
]
}
The engine returns:
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"qReturn": {
"qType": "GenericObject",
"qHandle": 2
}
},
"change": [
2
]
}
The list object is created and the handle is 2.
2. Select the first value of the field Country. The handle is 2.
The client sends:
{
"jsonrpc": "2.0",
"id": 2,
"method": "SelectListObjectValues",
"handle": 2,
"params": [
"/qListObjectDef",
[
0
],
false
]
}
The engine returns:
{
"jsonrpc": "2.0",
"id": 2,
"result": {
"qSuccess": true
},
"change": [
2
]
}
The first value of the field Country is selected.
3. Retrieve the first three values of the field. The handle is 2.
The client sends:
{
"jsonrpc": "2.0",
"id": 3,
"method": "GetListObjectData",
"handle": 2,
"params": [
"/qListObjectDef",
[
{
"qTop": 0,
"qLeft": 0,
"qWidth": 1,
"qHeight": 3
}
]
]
}
The engine returns:
{
"jsonrpc": "2.0",
"id": 3,
"result": {
"qDataPages": [
{
"qMatrix": [
[
{
"qText": "United States",
"qNum": "NaN",
"qElemNumber": 0,
"qState": "S"
}
],
[
{
"qText": "Denmark",
"qNum": "NaN",
"qElemNumber": 1,
"qState": "X"
}
],
[
{
"qText": "Spain",
"qNum": "NaN",
"qElemNumber": 2,
"qState": "X"
}
]
],
"qTails": [],
"qArea": {
"qLeft": 0,
"qTop": 0,
"qWidth": 1,
"qHeight": 3
}
}
]
}
}
The value United States is selected. The other values are excluded.
4. Get the handle of the field Country.
The client sends:
{
"jsonrpc": "2.0",
"id": 4,
"method": "GetField",
"handle": 1,
"params": [
"Country"
]
}
The engine returns:
{
"jsonrpc": "2.0",
"id": 4,
"result": {
"qReturn": {
"qType": "Field",
"qHandle": 3
}
}
}
The handle of the field Country is 3.
5. Get the properties of the field Country. The handle is 3.
The client sends:
{
"jsonrpc": "2.0",
"id": 5,
"method": "GetNxProperties",
"handle": 3,
"params": []
}
The engine returns:
{
"jsonrpc": "2.0",
"id": 5,
"result": {
"qProperties": {}
}
}
The list of properties is empty. The property qOneAndOnlyOne is set to false (since this property is not returned).
6. Set the property qOneAndOnlyOne in the field Country. The handle is 3.
The client sends:
{
"jsonrpc": "2.0",
"id": 6,
"method": "SetNxProperties",
"handle": 3,
"params": [
{
"qOneAndOnlyOne": true
}
]
}
The engine returns:
{
"jsonrpc": "2.0",
"id": 6,
"result": {},
"change": [
1,
2,
3
]
}
The property qOneAndOnlyOne is set.
7. Get the properties of the field Country. The handle is 3.
The client sends:
{
"jsonrpc": "2.0",
"id": 7,
"method": "GetNxProperties",
"handle": 3,
"params": []
}
The engine returns:
{
"jsonrpc": "2.0",
"id": 7,
"result": {
"qProperties": {
"qOneAndOnlyOne": true
}
}
}
The property qOneAndOnlyOne is set to true in the field Country. It is not possible to clear the field or make other selections in the field.
8. Clear the field Country . The result should be false since clearing is not allowed when the property qOneAndOnlyOne is set to true in the field.
The client sends:
{
"jsonrpc": "2.0",
"id": 9,
"method": "Clear",
"handle": 3,
"params": []
}
The engine returns:
{
"jsonrpc": "2.0",
"id": 9,
"result": {
"qReturn": false
},
"change": [
3
]
}
The result is false because it is not possible to clear the field.
9. Select the first and second values of the field Country. The result should be false since selecting more than one value in a field is not allowed when the property qOneAndOnlyOne is set to true in the field.
The client sends:
{
"jsonrpc": "2.0",
"id": 10,
"method": "SelectListObjectValues",
"handle": 2,
"params": [
"/qListObjectDef",
[
0,
1
],
false
]
}
The engine returns:
{
"jsonrpc": "2.0",
"id": 10,
"result": {
"qSuccess": false
},
"change": [
2,
3
]
}
The result is false because it is not possible to select two values in the field.