How to pass the clicked month as variable to the query?


I want to pass or get the {{currentRow._id.mont}} somehow to the
{{ downloadMonthDataParkingCosts.data }} -query, so I get only the data of that month.

It shouldn't be that hard, but somehow I'm struggling with it.

Who can enlighten me?

Hello @Tom_Suter!

In general, when you want to pass values to a query you would use the additionalScope function of a trigger. The way I usually do this is to setup my click handler to run a script and then write something like:

await yourQuery.trigger({ additionalScope: { month: currentRow._id.month } })

With your query, you can then use {{month}} (or whatever other additional scope key you send in the object) to use the value send from the script.

It looks like you are trying to export the data, so you could make JS Query to gather the downloadMonthDataParkingCosts.data values and filter them and then use the utils.exportData() method to bring it all together.

let monthData = downloadMonthDataParkingCosts.data
let monthPick = month
let yearPick = yearPicker.selectedItem
let fileName = 'monthly_parking_costs-' + yearPick + '-' + monthPick
utils.exportData(monthData, fileName, 'xlsx')

I hope this sends you down the path you seek!

3 Likes

That did the trick @pyrrho. Thank you.

1 Like