Okay, so we’ve got a bit carried away after this
:
Here’s another challenge solved in the same way — by creating a script working with our newly introduced History API.
Problem to solve
For each entity in a Database, get the maximum historical value of a certain Number Field.
For example, understand what was the peak revenue for each customer.
Solution
- Filter entities to avoid querying everything in a Database (History API is quite slow by design).
- For each entity, find the Field’s maximum historical value.
- Write the results into a CSV file for manual inspection.
- Take the CSV file and update another Field with the maximum historical value for each entity.
Here are the scripts:
As usual, feel free to use the scripts as is, fork them, or simply provide to your coding agent as an example when working with History API.
If you have any questions, please let me know!