Change value if undefined

Hi,

I am building an admin panel to get and modify a Firebase collection. I query the collection in a table, and then I made some columns editable.

So I wrote an update query:

{
"Aerate": {{NCSTasks.changesetArray["0"].Aerate}},
"Water":{{NCSTasks.changesetArray["0"].Water}},
}

Both integers and on the same row. And I created a button to trigger that query.

If I change only one value, the other goes undefined and removes whatever value I had already in that cell in Firebase as null.

I am not an experienced programmer, but I tried to write (using Retool AI) a "Transformer Results" code to check if the value is undenied and replace it with its original value (666 is temporary because I did not see when I can find the original value)):

const transformData = ((data) => {
for (const key in data) {
if (data[key] === null || data[key] === undefined) {
data[key] = 666;
}
}
return data;
})(data);
return transformData;

Maybe I am overthinking it, but my goal is to be able to change each value without affecting the other

If anyone can share some wisdom and help me, please.

Thank you in advance. :pray:

Hi @zouheir_bellouki,

This might work for you and prevent the need to a transformer:

image

It will fill the changesetArray with all column data so it's all available.

1 Like

Thanks a lot. That was easy enough to fix, I appreciate your time and help sir!

1 Like