Retrieve max value from a retool table and put it in localStorage

I normally use the code below to get a value from a retool table and put it into localStorage

localStorage.setValue ("minvnumber", table4.selectedRow.invnbr);

Now what if I wanted to get the maximum value of "invnbr" instead of the selected Row. What would be the code for that?

Mike

// Variables to hold max value
let maxValue = 0;

//converting the object to an array
const values = table4.data;

//Using the .map() method to loop the array, find maximum value
values.map((el) => {

//getting the value from each object and comparing to existing value
const valueFromObject = el.invnbr;
maxValue = Math.max(maxValue, valueFromObject);
});

//Printing out the result
console.log(maxValue);

jebit:

It worked perfectly! Thank you so much!

You have introduced me to an aspect of the language that I have not seen before.

This has gotten me over a big hurdle.

Thank you again. I have marked this as a solution.

Mike

Jebit:

I wanted to ask you one more question about the language you are using.

I take it that this is JASON.

I plan to study this language. Can I use this language in Retool? Currently I have been using to
tools written in JASON without really understanding the language.

Mike

Hi Mike
That is Javascript. You can use it in many places in Retool. Very handy to learn.
JSON is not a language - it's a way to format and store data.
cheers
Jebit.

Jebit:

Thank you very much.

I see that W3Schools has lessons on JavaScript.

Thanks again.

Mike

John:
I am having serious problems with transferring data from my tables back to the server with:
{{table2.recordUpdates}};

Is there some way of transferring data back to the server with JavaScript?

Mike