Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi,
I am creating a button in extension to copy all the possible values of a field to clipboard.
I can able to copy the selected values to clipboard,but i would like to get all the possible values to be copied?
How can i get the list of all possible values of a field in Qliksense extension?
Thanks,
John
Hi @agnie_john , I usually create a list box for getting all values of a field. You have to determinate how many rows has your field, then you can get all the data.
For this example I will use Engine APIs from extension code and reading 50 rows at the time from AsciiNum field
//Wait for Engine API promise
await qlik.currApp().model.enigmaModel.waitForOpen.promise
//Create a Listbox point to a specific field
const listBoxDef = {
"qInfo": {
"qType": "ListObject"
},
"qListObjectDef": {
"qStateName": "$",
"qLibraryId": "",
"qDef": {
"qFieldDefs": [
"AsciiNum"
],
"qSortCriterias": [
{
"qSortByLoadOrder": 1
}
]
}
}
}
const myListBox = await qlik.currApp().model.enigmaModel.createSessionObject(listBoxDef);
//Get layout
const myListBoxLayout = await myListBox.getLayout();
//Read data height
const myListBoxDataHeight = myListBoxLayout.qListObject.qSize.qcy
const dataPage = 50
//Loop over data height and reading data from field
for (let dataStep = 0; dataStep < myListBoxDataHeight; dataStep=dataStep+dataPage) {
let getDataDef = {
"qPath": "/qListObjectDef",
"qPages": [
{
"qLeft": 0,
"qTop": dataStep,
"qWidth": 1,
"qHeight": dataPage
}
]
}
//Method for reading data from field
const currentData = await myListBox.getListObjectData(getDataDef);
console.log(currentData)
}
hi @agnie_john ,
refer to these old posts
https://community.qlik.com/t5/QlikView-App-Dev/Get-Possible-Values-for-a-Field/td-p/540887
https://community.qlik.com/t5/QlikView-App-Dev/GetPossibleValues-Help/td-p/994708
the above 3 posts suggest the same solution, use concat of field
Hope this helps.
Hi @Rajashekar
Thanks for your reply.
yes I can use concat function in qliksense application.
But my requirement is to get the possible values of a field in the extension editor.
I am trying to create a button as an extension to copy all possible values of an field.
Thanks,
John
Hi @agnie_john , I usually create a list box for getting all values of a field. You have to determinate how many rows has your field, then you can get all the data.
For this example I will use Engine APIs from extension code and reading 50 rows at the time from AsciiNum field
//Wait for Engine API promise
await qlik.currApp().model.enigmaModel.waitForOpen.promise
//Create a Listbox point to a specific field
const listBoxDef = {
"qInfo": {
"qType": "ListObject"
},
"qListObjectDef": {
"qStateName": "$",
"qLibraryId": "",
"qDef": {
"qFieldDefs": [
"AsciiNum"
],
"qSortCriterias": [
{
"qSortByLoadOrder": 1
}
]
}
}
}
const myListBox = await qlik.currApp().model.enigmaModel.createSessionObject(listBoxDef);
//Get layout
const myListBoxLayout = await myListBox.getLayout();
//Read data height
const myListBoxDataHeight = myListBoxLayout.qListObject.qSize.qcy
const dataPage = 50
//Loop over data height and reading data from field
for (let dataStep = 0; dataStep < myListBoxDataHeight; dataStep=dataStep+dataPage) {
let getDataDef = {
"qPath": "/qListObjectDef",
"qPages": [
{
"qLeft": 0,
"qTop": dataStep,
"qWidth": 1,
"qHeight": dataPage
}
]
}
//Method for reading data from field
const currentData = await myListBox.getListObjectData(getDataDef);
console.log(currentData)
}