JS Query: How do I add a blank row to a temporary state/table

I have a temporary state and a table tied to it. I'm trying to write a JS Code to add a new blank row to the temporary state table without changing any of the existing rows. I've been messing around with setValue and setIn but I can't get them to do this. Either I use setValue and it creates a new line AND clears out the entire table, or I use setIn and it doesn't create a new row but updates an existing one.

Can someone please help? Here's the table, I guess I'd want it to create a new row similar to the existing row, without affecting the existing row/s

The following should work, I believe.


Thanks for the suggestion! I tried what you suggested but It returned an error "Temp_State_Detail.concat is not a function". I changed it to add ".value" like this


This does create a new detail row but it clears out everything that was previously keyed into the existing lines.

I also tried this

  "Line": 2,
  "Category": "Part",
  "Charge Description": "",
  "Qty": 0,
  "Unit Price": 0.00

but it seems to do something similar. Basically, any time I do a Temp_State_Detail.setValue, it adds a new row but reverts all lines back to their default state, clearing anything that was entered. I'm wondering if I should be interacting with the table instead of the Temp State?

The reason your getting the error is because you cannot use concat() if the Temp_State_Detail is not an array.

I got it to work by defining the initial value of Temp_State_Detail
as {{transformer1.value}}
which is defined as the following:
const objs = [];
return objs;

Then using an Event on the table such as Row Select, I call query2 which is defined as

Thanks for the detailed response. I did as you suggested. The only thing I did differently was to set the query2 to run on a button click. I also set the transformer1 as the following

Clicking the button adds a row but seems to wipe out anything already entered in the table. I'm not sure if this is similar to your experience or if I'm doing something wrong.

Basically, I want it so that when a user clicks the button to add a row, it leaves existing rows as they are, with any changes that had been entered into them, then it adds a new blank row set to "Part" Category.

Thanks for your help


Check out this article, not sure if you have read it yet, but I think it will give you what you're looking for...

Also, I think you may have to set the value of the table initially from a temp state so that you can run concat on it and this way it doesn't wipe out the original rows....so query1 in your case would be the initial temp state and then concat on that value and push it into another temp state which would be the value of the table itself

So, here's what I have done:
I have three temp states - each starting as objs that have structure but are empty - though they don't have to be.
mainTempState - this is the one I will use to update the db

Depending on what operation takes place, I will set temp1 to a value and then do
If I need to concat on that for temp2 I will do

Notice that I am never really changing but only adding to mainTempState...

For you mainTempState would be the value of your initial query and the source for your table.