Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

getLayout() return '-' values when called after createSessionVariable()

Using enigma, I try creating session variables before creating session object and getLayout.

  1. handle:1
  2. id:2
  3. jsonrpc:"2.0"
  4. method:"CreateSessionVariable"
  5. params:Array(1)
    1. 0:
      1. qDefinition:"GetFieldSelections(Date)"
      2. qInfo:{qType: "variable"}
      3. qName:"varDate"

This returns a GenericVariable.  Then I create session object


  1. handle:1
  2. id:4
  3. jsonrpc:"2.0"
  4. method:"CreateSessionObject"
  5. params:Array(1)
    1. 0:
      1. qHyperCubeDef:
        1. qDimensions:[]
        2. qInitialDataFetch:Array(1)
          1. 0:{qHeight: 1, qWidth: 1}
        1. qMeasures:Array(3)
          1. 0:
            1. qDef:{qDef: "sum({<Date={'$(varDate)'}, CLASS={'Extra'}>}TEST%)"}


This returns a GenericObject.  Then I tried checking if the session variables are created using GetVariableByName and GetProperties.  I won't display it here but I am able to see that the variable with the definition was indeed existing.  Then I call on getLayout() and got this in qMatrix


  1. qMatrix:Array(1)
    1. 0:Array(3)
      1. 0:{qText: "-", qNum: "NaN", qElemNumber: 0, qState: "L", qIsNull: true}


In short, I am not getting the value.  Next thing I did is to remove the creation of session variable in the code and run the app again.  This time, the GetVariableByName returns "Object not found".  But the getLayout() returned me the value.


  1. qMatrix:Array(1)
    1. 0:Array(3)
      1. 0:{qText: "0.345", qNum: 0, qElemNumber: 0, qState: "L"}


I would appreciate if you can explaiin me what's happening.

1 Reply
Øystein_Kolsrud
Employee
Employee

I think you need to modify the way you expand the variable in the hypercube. Try replacing {'$(varDate)'} with {'$(=$(varDate))'}. I think that should make Qlik Sense return the evaluated version of your variable instead of the unevaluated string "GetFieldSelections(Date)".

This thread covers a similar topic:Using variable in Set Analysis