☝️Small business or a startup? See if you qualify for our special offer.
+

Pivot Table Custom Error Handling

Answered
Will Aguiraud asked on February 11, 2025

Hello,

 

We are looking for a way to handle errors in Pivot Tables such as no data, fetch errors, etc. We would need a callback such that we can customize our error handling. Is there a way to do that? We use both Custom Data Source and regular client use, so it would have to work either way.

 

Best,

Will Aguiraud

11 answers

Public
Maksym Diachenko Maksym Diachenko Flexmonster February 11, 2025

Hello, Will!

Thank you for writing to us.

Yes, you can customize error handling in Flexmonster to manage different fault scenarios with different data sources. There are three key aspects to consider for implementing custom error handling:

Using events to track errors
You can listen to specific Flexmonster events to detect when an error occurs and take appropriate action. These include the olapstructureerror and the queryerror events for fetching the data with custom API and dataerror event for loading remote CSV/JSON. You can find the list of all available events on this page: https://www.flexmonster.com/api/events/

Showing own alerts
You can display the alert pop-up with a custom error message using the alert API call.

Overriding default error messages
The existing error messages can be customized via localization, in the localization.messages object. We want to mention that localization can be specified fully via file or partially by overriding specific labels (see example).

Please let us know if you need further guidance on the implementation.

Best Regards,
Maksym

Public
Maksym Diachenko Maksym Diachenko Flexmonster February 18, 2025

Hello, Will!

Hope you are doing well.
We would like to know whether you have tried the suggested approaches to customize error handling.
Looking forward to hearing your feedback.

Best Regards,
Maksym

Public
Will Aguiraud February 18, 2025

Hello Maksym,

 

Thank you very much for your quick response. It looks like the error events you mentioned are what we were looking for. Thank you!

Public
Maksym Diachenko Maksym Diachenko Flexmonster February 19, 2025

Hello, Will!

Thank you for your feedback.
We are glad to hear that one of our proposed solutions worked for your case.
Please let us know if any other questions arise.

Best Regards,
Maksym

Public
Will Aguiraud March 4, 2025

Hello,

The error event listeners are working as expected. However, is there a way to hide the error banner when using custom error handling? There doesn't seem to be a specific aria value or css class specific to errors we can use to hide error alerts.

 

Best,

Will

Public
Maksym Diachenko Maksym Diachenko Flexmonster March 5, 2025

Hello, Will!

Thank you for reaching out to us.

Flexmonster does not provide a direct way of disabling default error pop-ups because they provide essential information for troubleshooting. However, you can automatically close error pop-ups appearing in Flexmonster using the MutationObserver, as is shown in this example: https://jsfiddle.net/flexmonster/20etvg17/

Please let us know if this approach would work for you.

Best Regards,
Maksym

Public
Will Aguiraud March 6, 2025

Hi Maksym,

 

Thank you for your response.

 

One last question about this. We would also like to know when data has been successfully loaded into the pivot table (in this case, to hide our custom error banner). dataloaded doesn't work in a custom data source context, olapstructureloaded is what the documentation suggests using in that case. However, olapstructureloaded is fired when the /fields call is successful, not when the /select call is. reportcomplete seems to be getting fired at the right time, but it gets fired when there's errors as well. Is there a way to know when there is a successful data load (without errors)?

 

Best,

Will

 

 

Public
Maksym Diachenko Maksym Diachenko Flexmonster March 6, 2025

Hello, Will!

Thank you for reaching out to us.

For such an advanced approach to error handling, we recommend using a functional API for greater control over individual request processing. This approach allows you to define a function as an API endpoint in the dataSource.url parameter:

    dataSource: {
type: "api",
url: pivotEndpoint,
index: "fm-product-sales",
}

For your use case, this function should act as a proxy between Flexmonster and your server, forwarding requests while implementing response error handling. This ensures that network failures, invalid responses, or other issues can be properly managed before data reaches the pivot table.

You can reference this JSFiddle, which demonstrates the implementation of a functional endpoint forwarding requests to the server: https://jsfiddle.net/flexmonster/h3k2qwe1/. Kindly note that error-handling logic should be implemented on your end.

Please let us know if any questions arise.

Best Regards,
Maksym

Public
Will Aguiraud March 6, 2025

Hello Maksym,

 

Thank you for your quick response. Could you please share documentation that would explain this approach in more detail? We can't find any mention of it in the documentation.

Public
Maksym Diachenko Maksym Diachenko Flexmonster March 7, 2025

Hello, Will!

Thank you for your reply.

You can find a more in-depth explanation of the function-based approach for custom API connection in this support forum thread: More user friendly way to tell the user there is no data when using Custom Data Source API

Also, remember that this approach can cause issues when saving the report as a JSON file. The saved report JSON does not include the function from the url parameter. This means the report cannot be restored without manually reattaching the function after loading the saved configuration.

If saving and reloading reports is crucial for your project and you want to avoid such workarounds, you might want to consider a different approach to handling server errors.

We are looking forward to hearing your feedback.

Best Regards,
Maskym

Public
Maksym Diachenko Maksym Diachenko Flexmonster 7 days ago

Hello, Will!

Hope you are doing well.
We are wondering if you implemented the server response error handling using a function for custom API connection.
Please let us know if you need any further assistance.

Best Regards,
Maksym

Please login or Register to Submit Answer