How to insert new modified date

I am trying to do a bulk update on table data, and wish to set the 'modified date' to {{moment()}}, how do i insert that new modified date into the array or {{table1.recordUpdates}}??

Thanks

Hey @mhunwick!

You can try using some JavaScript here - since each row in the recordUpdates array is an object you can use Object.assign to pass it new values before sending it off to your bulk update query. Maybe something like this?

{{ table1.recordUpdates.map(record => Object.assign(record, {date: moment().format()})) }}

Let me know if that works!

@Kabirdas is it possible to insert a calculation in here? Whenever I try.. the Query runs forever and doesnt time out. No error messages are posted. I left it run all night to see if it would eventually time out and give me some kind of error.. but when I woke up, it was still running.

ie:

{{ table1.recordUpdates.map(record => Object.assign(record, {date: moment().format()}, {total_count: (table1.recordUpdates[i].field1 + table1.recordUpdates[i].field2)-table1.recordUpdates[i].field3)) }}

If i use only your example it runs fine, without issue. As Soon as I add a calculation to it, it runs forever and the only way to stop it is to reload all queries or refresh the page.

Hey @cpearson4772!

Hmm... this may be a result of copying into the forum post but it looks like there's a missing }:

Otherwise, are you calling this query from a listview or table? I'm curious how the i variable is being populated. If it's just meant to be the same index as the record you're doing the calculation on you might try something like:

{{ table1.recordUpdates.map(record => Object.assign(record, {date: moment().format(), total_count: record.field1 + record.field2 - record.field3})) }}

@Kabirdas Thanks for the reply.

The calculation is coming from a table. Its basically an Inventory Tracking Table. ([productsInInventory]+[productsAddedToInventory])-[productsSold] = [onHandInventory]

When I tried your method above, I get null.

Got it, thanks for that screenshot! In that case you'd want:

{remaining_count: item.initial_count + item.re_up_count - item.sold_count}

The idea is that whatever variable is being declared in the => function (in this case item) should hold all the properties of the record you're updating, including the corresponding counts.

Can you let me know if that works?

@Kabirdas ... you are the MAN. It worked! Thank you so much for your help and for the explanation. Much appreciated.