Hi All,
I have a table column which is populated by a rest api. The data is an array with multiple records.
I would like to get only one value back and only for the record that is the newest, based on date or the highest id number
[{"id":173418693,"offer_data_id":2217344,"stock":7,"sold":0,"revenue":"0.00","price":7.95,"status":"success","created_at":"2022-12-17T15:25:24.000000Z","updated_at":"2022-12-17T15:25:24.000000Z"},{"id":174660695,"offer_data_id":2217344,"stock":7,"sold":0,"revenue":"0.00","price":7.95,"status":"success","created_at":"2022-12-18T16:22:58.000000Z","updated_at":"2022-12-18T16:22:58.000000Z"},{"id":175895890,"offer_data_id":2217344,"stock":7,"sold":0,"revenue":"0.00","price":7.95,"status":"success","created_at":"2022-12-19T03:19:03.000000Z","updated_at":"2022-12-19T03:19:03.000000Z"},{"id":177135277,"offer_data_id":2217344,"stock":7,"sold":0,"revenue":"0.00","price":7.95,"status":"success","created_at":"2022-12-20T15:36:03.000000Z","updated_at":"2022-12-20T15:36:03.000000Z"},{"id":178392787,"offer_data_id":2217344,"stock":27,"sold":0,"revenue":"0.00","price":7.95,"status":"success","created_at":"2022-12-21T03:09:37.000000Z","updated_at":"2022-12-21T03:09:37.000000Z"}]
If you look at this case I would need to return the value from the field stock, in this case it should return the number 27 because this is the "newest" record based on id and date.
I can get all the stock nicely formatted in a custom column with below code but not sure how to add the above logic to only show the newest record.
{{ean.data[i].tracked_products.map(d=>d.stock).toString()}}