We have updated Flexmonster Software License Agreement, effective as of September 30, 2024. Learn more about what’s changed.

template or literal variable

Answered
Paul Schlichter asked on February 21, 2022

I have a page where the current year, month, etc is populated as a javascript variable when the web page is loaded. I would like to set up filters where the web page variable is pulled in to the filter on the flexmonster grid.
Sometimes would use the current year variable to set the fiscal year or period.
Example: reportFilters: [ {uniqueName: "year", filter:{members:['year.[varyr]','year[varyr2]']}}
 
where varyr and varyr2 are defined as variables when the web page is loaded
It is like a template variable. Is this possible
Thanks
Paul

3 answers

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster February 21, 2022

Hello, Paul,
 
Thank you for reaching out to us.
 
It is possible to use a variable to set the Report Filter in Flexmonster. For example:

let slice = flexmonster.getReport().slice;
slice.reportFilters = [{
"uniqueName": "Year",
"filter": {
"members": [
`Year.[${date}]`
]
}
}];
flexmonster.runQuery(slice);

You can see the example on the following JSFiddle for reference: https://jsfiddle.net/flexmonster/onmag0u8/
 
Please let us know if it works for you. Feel free to contact us if other questions arise.
 
Kind regards,
Nadia

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster February 28, 2022

Hello, Paul,
 
Hope you are doing well.
 
We were wondering if you had a chance to test a suggested approach.
 
Looking forward to hearing your feedback.
 
Kind regards,
Nadia

Public
Nadia Khodakivska Nadia Khodakivska Flexmonster March 7, 2022

Hello, Paul,
 
Hope you are doing well.
 
Just checking in to ask if you found a suggested approach helpful.
 
Our team would be grateful for your feedback.
 
Kind regards,
Nadia

Please login or Register to Submit Answer