Hello,
We give favorite functionality for our customers. So when saving the flex report definition and restoring it, we have an issue with filters. When we use index for data, filters work fine when restoring the favorite using setReport, but when using json data, the filters are not restored. Please see a sample of what I use in setReport function
Please let me know how to solve this issue
Thanks
Sri
TeleBright
{
"dataSource": {
"type": "json"
},
"slice": {
"columns": [
{
"uniqueName": "Order #"
},
{
"uniqueName": "Order Type"
},
{
"uniqueName": "Vendor",
"filter": {
"members": [
"vendor.[at&t wireless]"
]
}
},
{
"uniqueName": "Account #"
},
{
"uniqueName": "Order Date"
},
{
"uniqueName": "Request Date"
},
{
"uniqueName": "Order Status"
},
{
"uniqueName": "Vendor Order #"
},
{
"uniqueName": "Placed By"
},
{
"uniqueName": "[Measures]"
}
]
},
"options": {
"grid": {
"type": "flat",
"showTotals": "off",
"showGrandTotals": "off"
}
},
"formats": [],
"version": "2.9.104",
"creationDate": "2025-05-27T09:23:33.103Z"
}
Hello Sri,
Thank you for contacting us.
When restoring filters using the setReport
API call, the data source must contain all the necessary values corresponding to the selected filters (specifically, the same uniqueNames and member values used in the report you want to set).
In the provided sample, the dataSource
object only includes the type
property. If you're using a JSON data source, please ensure it includes either the filename
property (pointing to the correct remote data URL) or the data
property with the appropriate inline JSON. You are welcome to check more details regarding the JSON data source in our documentation: https://www.flexmonster.com/doc/json-data-source/
To sum up, without the actual data that matches the filter criteria, the filters in the restored report cannot be applied correctly.
Also, why do you want to switch from the index to a JSON data source? It would greatly help us to understand your use case better.
Looking forward to hearing from you.
Kind regards,
Nadia
Hello Nadia,
Adding the data as json worked. The filters are applied correctly now.
We switched to the json method rather than indexes since we have many customers and we had to create the same report for each customer. We used query method for creating the flex index and so we had to use the same query with different customer keys in different indexes.
Thanks
Sri
Hello Sri,
Thank you for the feedback and for sharing the details about your use case.
We are glad to hear that the suggested solution works for you.
You are welcome to contact us if other questions arise.
Kind regards,
Nadia