Custom Data Source: Fields Update

Answered
Sengupta asked on August 9, 2021

Hi there
Is there a way to force execute a "fields" type API?
https://jsfiddle.net/Sengupta/c2Lrn15d/21/
When Flexmonster loads, it calls "handshake", "fields", "members", "select" end-points
14:26:04
{"type":"handshake","version":"2.9.5","requestHeaders":{}}
14:26:04
{"index":"fm-product-sales","type":"fields","requestHeaders":{}}
14:26:04
{"index":"fm-product-sales","type":"members","field":{"uniqueName":"Color"},"page":0,"requestHeaders":{}}
14:26:04
{"type":"select","index":"fm-product-sales","query":{"aggs":{"by":{"rows":[{"uniqueName":"Color"}]},"values":[{"func":"sum","field":{"uniqueName":"Price"}}]}},"page":0,"requestHeaders":{}}
 

On flexmonster.updateData, it only call "members", "select"
14:30:06
{"index":"fm-product-sales","type":"members","field":{"uniqueName":"Color"},"page":0,"requestHeaders":{}}
14:30:07
{"type":"select","index":"fm-product-sales","query":{"aggs":{"by":{"rows":[{"uniqueName":"Color"}]},"values":[{"func":"sum","field":{"uniqueName":"Price"}}]}},"page":0,"requestHeaders":{}}
 

We need this as in our system more "fields" are added from other sources on runtime 

4 answers

Public
Sengupta August 9, 2021

Please note I even tried to force the call to "fields" end-point by changing the "index” value.
On these occasion, the Flex Monster API do call all “handshake”, “fields”, “members”, “select” end-points.
But this cause the table presentation either go blank or in a grey scale

Public
Vera Didenko Vera Didenko Flexmonster August 10, 2021

Hello,
 
Thank you for writing to us and for sharing an example.
 
For such cases, we would recommend the following approach:

  1. Save the current report configuration with the getReport() API call.
  2. Use the clear() API call to clear the report in Flexmonster.
  3. Restore the report configuration with the setReport() API call. Since the report was cleared in the previous step, Flexmonster will execute all requests, including /fields.

Here is a modified version of the JSFiddle showing this approach: https://jsfiddle.net/flexmonster/w3u7fzed/.
 
Please let us know if this works.
 
Kind regards,
Vera

Public
Sengupta August 10, 2021

@Vera
Reloading the reports has a negative performance hit.
How can we update the "Fields" only?
Regards
Anirban

Public
Vera Didenko Vera Didenko Flexmonster August 11, 2021

Hello, Anirban,
 
Thank you for your response.
 
Due to the current architecture, the fields define the data structure.
If new members are added to fields, you can use the updateData() API call to refresh the data in Flexmonster.
However, if more fields are added to the data set, Flexmonster needs to reload the structure, including the current report.
With this in mind, the /fields request can't be initiated on its own. If you need to add new fields for the custom data source API, the best approach is to reload the report.
 
Feel free to contact us if other questions arise.
 
Kind regards,
Vera

Please login or Register to Submit Answer