Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Dear all,
There is requirement to create mashup page from existing application with default max month and max year to be selected.
In application, default showing all year and month data which should be keep as it is but while showing chart from this application into mashup page the always selected year and month to be max.
is it possible ? how?
kindly suggest.
Hi,
Please verify the below
app.field("Year").selectValues([2023], true, true);
// OR try
app.field("Year").selectValues(["2023"], true, true);
Final code:
var app = qlik.openApp('dummyCal.qvf', config);
//get objects -- inserted here --
app.getObject('CurrentSelections','CurrentSelections');
app.getObject('QV01','sbrRa');
/*
// alternate (not recomended)
app.createGenericObject( {
vMaxYear: {
qStringExpression: "=vMaxYear"
},
vMaxMonth : {
qStringExpression: "=vMaxMonth"
}
}, function ( reply ) {
var month = reply.vMaxMonth,
year = reply.vMaxYear;
console.log(month,year);
//app.field("Year").selectValues([year], true, true);
app.field("Month").selectValues([{qText: month}], true, true);
});
*/
/*
app.variable.getByName('vMaxYear').then(function(model){
console.log(model.qContent.qString);
});*/
app.variable.getContent('vMaxYear').then(function(model){
var a = parseInt(model.qContent.qString);
console.log(model.qContent.qString,a);
app.field("Year").selectValues([a], true, true);
});
app.variable.getContent('vMaxMonth').then(function(model){
console.log(model.qContent.qString);
app.field("Month").selectMatch("Dec", true);
});
Hi,
You need to take certain steps to achieve this,
Follow the above steps & value will be selected by default while mashup HTML is loading
Hi Ajay,
Thank you for your response. Here I have created and want to check if its correct as per your steps:
Hi,
Change below to:
var app = qlik.openApp('APPID_HERE', config);
//max year -> do the same for month OR can use YearMonth & get a max out of it
app.variable.getByName('MyVarName').then(function(model){
console.log(model,model.layout.qText); // this will give you the result capture it & then store it in variable
app.field("FieldName").selectValues([model.layout.qText], true, true);
},function(errorObject){ console.log(errorObject); } );
Hi Ajay,
This is how changed but still I am getting all the values in year filter:
this means your select is failing - is year a number or string? try using qNum instead of qText
Hi edwin,
This is my final js code, I have changed qtext to qnum but no luck so far:
Hi,
Please verify the below
app.field("Year").selectValues([2023], true, true);
// OR try
app.field("Year").selectValues(["2023"], true, true);
Final code:
var app = qlik.openApp('dummyCal.qvf', config);
//get objects -- inserted here --
app.getObject('CurrentSelections','CurrentSelections');
app.getObject('QV01','sbrRa');
/*
// alternate (not recomended)
app.createGenericObject( {
vMaxYear: {
qStringExpression: "=vMaxYear"
},
vMaxMonth : {
qStringExpression: "=vMaxMonth"
}
}, function ( reply ) {
var month = reply.vMaxMonth,
year = reply.vMaxYear;
console.log(month,year);
//app.field("Year").selectValues([year], true, true);
app.field("Month").selectValues([{qText: month}], true, true);
});
*/
/*
app.variable.getByName('vMaxYear').then(function(model){
console.log(model.qContent.qString);
});*/
app.variable.getContent('vMaxYear').then(function(model){
var a = parseInt(model.qContent.qString);
console.log(model.qContent.qString,a);
app.field("Year").selectValues([a], true, true);
});
app.variable.getContent('vMaxMonth').then(function(model){
console.log(model.qContent.qString);
app.field("Month").selectMatch("Dec", true);
});
Hi Ajay,
Thanks. This code works for me .
var a = parseInt(model.qContent.qString);
console.log(model.qContent.qString,a);
Hello everyone, I often read your stuff and actively participate in this conversation. Check out this page as well. accessmcd