Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello, I am developing a JS script to basically download all metadata from QS applications and I have a problem with pulling list of all objects with their dimensions/measures.
What I managed to find out is to use methods like getObjects or getLayout to get list of the objects and add "/qHyperCubeDef" in the parameters, but it returns way too much uneccessary data and slows down the reload time by over 10 times which is unacceptable for me as I'm running it for dozens of apps at once.
Here is an example with simple getObjects method:
const param = {
"qOptions": {
"qInfo": {
"qTypes": [ "barchart" ], // aiming bar charts just for example
"qIncludeSessionObjects": false,
"qData": {
"Test_qHyperCubeDef": "/qHyperCubeDef"
}}}}
const data = await app.getObjects(param);
The output is a list of charts with both tables:"qHyperCubeDef" but also "qHyperCube" which is few times bigger and I do not need it at all. Fun fact: When I go with "Test_qHyperCube": "/qHyperCube" in the parameters, I will only get qHyperCube data without the qHyperCubeDef.
I know there's a way to go deeper with the parameters, so I tried to go one level deeper into the tables I really need, which are qDimensions and qMeasures inside qHyperCubeDef.
"Test_qDimensions": "/qHyperCubeDef/qDimensions",
"Test_qMeasures": "/qHyperCubeDef/qMeasures"
This way however does not work at all and returns no data. Both qDimensions and qMeasures are arrays with multiple dimensions and measures and I found out that when I add index of the array value it will work, but it's still just 1 dim/measure at a time.
"Test_qDimensions": "/qHyperCubeDef/qDimensions/0",
"Test_qMeasures": "/qHyperCubeDef/qMeasures/0"
The info I am only interested in is in that path "/qHyperCubeDef/qDimensions/0/qDef" of course without specifying the index 0/1/2/3 of a dimension/measure.
Do you know if there is a way to modify the parameteres so it returns all data? Or is there a different way to build a single query that will return list of visualizations and all their dimensions/measures?
I try to avoid creating a loop on object level and using something like getObject() one after another because it also slows down the script a lot.
Thanks in advance!
Hi @skoscielny I've tried your call to GetObjects with the first body you posted and I received "Unexpected JSON token". Below my request
{
"handle": 1,
"method": "GetObjects",
"params": {
"qOptions": {
"qTypes": [
"table"
],
"qIncludeSessionObjects": false,
"qData": {
"qHyperCubeDef": "/qHyperCubeDef"
}
}
}
}
I'm trying to understand if this method can help you requirement.
Meanwhile, I have another approach, but you need to at least loop over all your sheets within an app.
Basically, first you have to get all the sheets, and then starting from a single sheet, perform a GetFullPropertyTree call where you will find all the objects and relative definitions with dimensions, meausures and all other configurations. Let me know if this approach can work
Hello @alex_colombo,
I apologize, it is my bad. I wanted it to look more straightforward but actually the exact table name cannot be referenced.
Please use any name you want like "Test":"/qHyperCubeDef". I will correct the post.
By looping through sheets I won't get information about master visualizations that are not used on any of the sheets. Additionally I don't think there is possibility to filter it since GetFullPropertyTree() does not accept any parameters.
Even if I go this way, I will still will have to figure out how to create a query to pull properties of master visualizations. If I would create one, I could just extend it so it could cover all visualizations instead of just master.
Hi @skoscielny afaik there is no other way for getting just dimensions and measures for all objects of an app. I'm quite sure that you have to loop over all objects for reading dimensions and measures, even if there is a method for just having dimensions and measures. So, you will need a loop for sure.
I'm not understanding when you mentioned that a loop slow it down your script a lot. After you received the big response you have just to point to dimensions and measures arrays and then loop over them.