Boost Your Flexmonster Experience with UpdateData API Call

There are tons of features you can combine in Flexmonster to reach the pivot table functionality you need. On our YouTube channel, we have started a series of videos called “Tips & Tricks” where we share different interesting approaches to maximize your Flexmonster experience.

The last video, Live data refresh/update hack, explains the details of updateData() API call usage. In this blog post, we will delve into the topic and see how it works from the inside.

Understanding the updateData() API call

updateData() allows you to refresh the data in your report without altering the report structure itself. When you trigger the function, only the DataSourceObject is modified, while the report's settings, such as number formatting, conditional formatting, and scroll position, are retained.

How updateData() Works?

Each time the updateData() API is called, the component sends a request for the updated data, which is then fetched over the network and displayed on the report.

flexmonster.updateData({
  type: 'csv',
  filename: 'https://cdn.flexmonster.com/data/retail-data.json'
});

However, it's important to note that attempting to update the data multiple times may not yield results. This is because the updateData() API call only triggers an update when the link in the data source parameter differs from the one already present in the report.

Ensuring Data Update Success

If you change the data in the file but leave the file name the same, Flexmonster will not reload the data several times as neither the link nor type has changed. Therefore, to make sure that such a file is successfully updated, you can append some unique value to the URL query string that will not be repeated, for example, the current date as the Unix timestamp.

function updateData() {
  flexmonster.updateData({
    type: "json",
    filename: "https://cdn.flexmonster.com/data/retail-data.json?" + Date.now()
  });
}

This simple workaround guarantees the uniqueness of the URL, prompting the data to be updated effectively.

On our YouTube channel, you can watch the full tutorial and see how the approach works on the demo.

When to use updateData() API call?

In conclusion, utilizing the updateData() API call in Flexmonster can streamline your reporting process by enabling seamless data updates without compromising your report settings. By following the suggested workaround with the Unix timestamp, you can ensure that your data is consistently refreshed for accurate insights.

But you are not limited to this approach! Here, you can see other examples of updating data on the grid:

Thank you for reading this article! If you’ve liked it – stay tuned for more valuable tips and tricks in our future content here in the blog and on our YouTube channel.

Subscribe to our news: