Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
agnie_john
Partner - Contributor II
Partner - Contributor II

Get all the Possbile values of a Field in QlikSense Extension

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

Labels (1)
1 Solution

Accepted Solutions
alex_colombo
Employee
Employee

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)
}

 

 

View solution in original post

3 Replies
agnie_john
Partner - Contributor II
Partner - Contributor II
Author

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

alex_colombo
Employee
Employee

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)
}