Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
akeswani
Creator
Creator

GetLayout method not returning selections

Hello,

I am using Angular4, and trying to get selections on QS app.

This is how I am calling createsessionobject first:

return new Promise((resolve, reject) => {
        var createSessionSelectionMsg = {           
           "jsonrpc": "2.0",            
           "id": 2,
           "method": "CreateSessionObject",
           "handle": parseInt(handle),
           "params": [
              {
             "qInfo": {
             "qId": "",
             "qType": "SessionLists"                   
              },     
               "qSelectionObjectDef": {}
              }
            ]
} .........

after that I am calling GetLayout

return new Promise((resolve, reject) => {

   var glayout = {

   "jsonrpc": "2.0",

  "id": 2,

  "method": "GetLayout",

  "handle": 2 ,//parseInt(handle),

   "params": []

}

...

The above two returns this result--

result:
qReturn:
   qGenericId: "13f471d2-ee35-480d-a965-a98d783abbc2"
   qGenericType: "SessionLists"
   qHandle: 2
   qType: "GenericObject"

result:

qLayout:

qInfo: {qId: "13f471d2-ee35-480d-a965-a98d783abbc2", qType: "SessionLists"}

qSelectionInfo:{ }

qSelectionObject: {qBackCount: 0, qForwardCount: 0, qSelections: Array(0)}

I am selecting a field value on the app, but the qSelections is not returning anything, don't know why.

am I calling the above correctly?

Can anyone please help me ?

Thanks!

1 Solution

Accepted Solutions
ErikWetterberg

‌Hi,

The id field is just an id for the message, need to be unique, just using a sequential number is good.

The message ’method not found’ means you are trying to call GetLayout on an object Thatcher does not have usch a method. Probably the handle valurnorna is wrong.

Erik Wetterberg

View solution in original post

10 Replies
ErikWetterberg

‌Hi,

are you using enigmajs? Or capabilities API? Or building something yourself?

Erik Wetterberg

akeswani
Creator
Creator
Author

Thanks Erik,

I am just building a web app with angular front end, displaying our Qliksense apps list and when click on a app, it opens up the app.

I am able to get the selections list, how can I send a link to a user so if he opens up the link ,he should see the same selections on the same app on the hub? trying to use GetField and SelectValues but not sure, it's not working yet.

akeswani
Creator
Creator
Author

Actually the GetField and SelectValues are working now, sorry I am new to Qlik, so taking some time to get it work.

How can I send this as a link ? so if user opens it up ,he should see the same app + Sheet + selections ???

Thanks in advance.

akeswani
Creator
Creator
Author

So I am able to create a link, so if the user clicks that, then I would call Engine API to display the fields with those selection values. (The user would see the link when he in the same app. )

this is not working yet.

I am calling GetField and SelectValues, then after going through documentation, I think I need to call GetLayout also.

I am passing in the field handle (returned by getfield) in GetLayout (what is this id here I don't know..):

var getlayout = {

   "jsonrpc": "2.0",

   "id": 2,

   "method": "GetLayout",

   "handle": parseInt(handle),

   "params": []

}

...

  resolve(data.result.qLayout.qSelectionObject.qSelections);

....

Getting an error :

error:

code: -32601

message: "Method not found"

parameter: "GetLayout"

although the same method is used in getting selections (CreateSessionObject + GetLayout) and is working there. is there a problem with field handle ? or is it something else ?

Please help.

Thanks.

ErikWetterberg

‌Hi,

The id field is just an id for the message, need to be unique, just using a sequential number is good.

The message ’method not found’ means you are trying to call GetLayout on an object Thatcher does not have usch a method. Probably the handle valurnorna is wrong.

Erik Wetterberg

akeswani
Creator
Creator
Author

Does it mean that the "field" handle cannot be passed to GetLayout ? if so, how would I get the selections displayed then?

  this.getField(qlikWs, element.qField, appHandle).then(reply => {

  console.log('select field', fieldHandle) // this returns 2

   this.selectValues(qlikWs, fieldHandle, element.qSelected).then(reply => { // this returns true in qReturn

    this.getLayout(fieldHandle, qlikWs).then(sel => { // this throws error

Thanks Erik.

akeswani
Creator
Creator
Author

I was watching a video on QS Engine API explorer, it's a good way to test APIs.

So ,I tested to apply selections with Getfield and SelectValues, then I called the Macros->List Selections, it showed me the CreateSessionObject and GetLayout to be called. When I hit execute, the GetLayout does not return qSelections.

I think I need to pass in the selections  in CreateSessionObject, so GetLayout knows and can pick it up.

This is what it shows me:

"method": "CreateSessionObject",

"handle": 1,

"params": [

  {

   "qInfo": {

    "qType": "CurrentSelection"

   },

   "qSelectionObjectDef": {}

  }

],

...

How can I pass current selections in this ? I tried something like this below in qSelectionObjectDef, but this doesn't return selections in GetLayout:

"qSelectionObjectDef": {

     "qSelections": [{

      "qField":"Weekday",

      "qSelected":"Tue"

     }

     ]

    }

I think this is not correct as qSelectionObjectDef is for passing in Definitions/structures of objects and not values, is that right ? if I can pass the selections in CreateSessionObject, then it will probably work.

How can I pass selections above ? I also tried

"qSelectionObject: {

     "qSelections": [{

      "qField":"Weekday",

      "qSelected":"Tue"

     }

     ]

    },

qSelectionObjectDef:{}

but nothing works as of now. 😞

akeswani
Creator
Creator
Author

So it is working for me. The problem that I was passing the selected values in SelectValues method has qIsNumeric set to false, and I kept testing with the field "Weekday" that ,to my surprise, is set to numeric type. Once I set that to true, it worked and showed me the selection on the app.

  "qText": val ,

   "qIsNumeric": true 

I ran "List Fields" macro on engine api explorer and got this info:

{

      "qName": "Weekday",

      "qCardinal": 7,

      "qTags": [

       "$numeric",

       "$integer"

      ],

      "qSrcTables": [

       "datetime"

      ]

     },

Now, to know the selected fields are numeric or not, is there an easy way to get that info? so I can pass that to SelectValues.

akeswani
Creator
Creator
Author

So Erik, it's working to some extent. Can you help me with SelectValues method. it works for non-numeric field types. But for , say Weekday field which is numeric, I need to pass in the following info :

"qText": "Thu",

    "qIsNumeric": true,

    "qNumber": 0

I am calling GetFieldDescription method to get the "qIsNumeric" value and passing it to SelectValues method above.

Now, I need to know the "qNumber" value also. The method takes 0 as default, and is showing "Sun" as selected value, although it should be "Thu" (for which the qNumber should be 4) . How do I know the qNumber of text that I am passing in ? can I call a method that returns me this info?