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

How To pass values in field based on condition in selectMatch api

Hi All,

I am using below API to pass a value in field
app.field('reporting_year').selectMatch(String(new Date().getFullYear()), true)


Is it possible ,if user has already selected a value in "reporting_year" field than pass user selected year else current year (2022)

Using this but  its not working in mashup
if(GetSelectedCount('reporting_year')=0,app.field('reporting_year').selectMatch(String(new Date().getFullYear()), true));

@edwin 

Labels (2)
1 Solution

Accepted Solutions
edwin
Master II
Master II

going through that link shows you how to create a hypecube and does some explaining.

once you get that, a faster way to code is to select your application in DEVhub:

edwin_0-1655912010995.png

click add hypercube:

edwin_1-1655912042108.png

 

then choose your dimensions and measures.  it will create the code for you and you can just move that piece of code anywhere you want

View solution in original post

5 Replies
edwin
Master II
Master II

GetSelectedCount is a function in Qlik Sense not in javascript.  you are mixing up the syntax of Qlik Sense expressions and javascript:

Qlik Sense: if(condition, true, false)

javascript: if (condition) 
                           {true}
                       else
                           {false}

it looks like you want to know if there are selected values for reporting year - unfortunately, you need to get that info via api.  a hypercube may be usefull. wouldnt you want your webpage to know not just if there are selected rep years but also what was selected and all possible selections?  that can be retrieved via hypercube

Qlik1_User1
Specialist
Specialist
Author

@edwin can you please help in creation of a hypercube , I am new to mashup,  i am not aware how to achieve this.

edwin
Master II
Master II

go through this:

https://help.qlik.com/en-US/sense-developer/May2022/Subsystems/APIs/Content/Sense_ClientAPIs/Capabil...

it shows you how to create hypercubes.  this allows you to get data from your dashboard - almost like a straight table.  you can use rep year as your dimension and just create measures to tell you which ones are selected.

edwin
Master II
Master II

going through that link shows you how to create a hypecube and does some explaining.

once you get that, a faster way to code is to select your application in DEVhub:

edwin_0-1655912010995.png

click add hypercube:

edwin_1-1655912042108.png

 

then choose your dimensions and measures.  it will create the code for you and you can just move that piece of code anywhere you want

edwin
Master II
Master II

hypercubes are returned as promises.  you may also want to read up on that:

JavaScript Promises: an introduction (web.dev)