How to manually update a table cell using Javascript (changesetArray variable)?

I am new to Retool and I need to manually update a table cell using JavaScript.

It appears the changesetArray is read only so I need to find another way to update a table cell value.

I exhaustively read the community board and found nothing concrete how to do this.

I have the shell query code ready to go. It matches the IOFunction/PinCavity value from the selected value from the new table against the main table to provide the matching relevant cell value. In this example, I select a Pin cavity, I will know what's its matching I/O function value (example: select pin cavity J1-2 and its I/O Function is FuncA).

Below is the shell query code:

// Loop through Connector & Pinout I/O table data rows.
(async () => {
// Set variable "selectedRows" value for Connector & Pinout table.
var selectedRows1 = table1.changesetArray;

         // Set variable "selectedRows" value for the Power Requirements table.
          var selectedRows9 = table9.changesetArray;

              // Loop through Power Requirements table array items.
              for (let i = 0; i < selectedRows9.length; i++) {

// Print to console each loop count.
//console.log(i);

              // Get the I/O Function & Pin cavity values from the Connector & Pinout I/O data table.
              var IOFunc9 = table9.changesetArray[i].IOFunction;
              var PinCav9 = table9.changesetArray[i].PinCavity;

                  // Loop through Power Requirements table array items.
                  for (let z = 0; z < selectedRows1.length; z++) {
                  
                  // Get the I/O Function & Pin cavity values from the Power Requiremnts I/O data table.
                  var IOFunc1 = table1.changesetArray[z].IOFunction;
                  var PinCav1 = table1.changesetArray[z].PinCavity;

                      // Continue if there is a matching IO FUNCTION value in the cell found.
                      if ( IOFunc1 === IOFunc9 ) {

console.log(z); // Index value (row) for the Connector & Pinout table.
console.log('This row a matching I/O FUNCTION value!!!!'); // Print to screen.
console.log(i); // Index value (row) for the Power Requirements table.
console.log(IOFunc1); // I/O Function (pin name) of selected from drop-down list.
console.log(PinCav1); // Pin cavity from the selected drop down list.
console.log(window.DevicePinCavity);
console.log('.............................................');

// I know what the table index value to write to is and the value I want. I just need to know how to update the table with the new value.

                        // Exit outer for loop.
                        //break;
                        
                      } else if ( PinCav1 === PinCav9 ) {
                                 // Continue if there is a matching PIN CAVITY value in the cell found.

                                 // Set the global selected I/O Function value (used later by other tables).
                                 window.DeviceIOFunc = IOFunc1;

//
console.log('This row a matching PIN CAVITY value!!!!');
console.log(i);
console.log(PinCav1);
console.log(IOFunc1);
console.log('##############################################');

                               // Exit outer for loop.
                               //break;
                        
                               }
                 };

              };

})();

How can I manually update the new table with both values? (one selected, the other referenced from main table)

So in other words, If I select the pin cavity J12 in the new table, how can I populate the I/O function value of FuncA in the new table and vice versa?

Can someone be a hero and help me please?

Thank you!

Adding visual console.log output for IOFunction/Pin cavity data report:

console

this topic might be what you're looking for.

in general, the datasource for table1 should be a variable. this lets table9 events modify the data table1 is using. let me know if I'm way off and none of this helps.

That looks too complicated for me to figure out.

I see "..." in the example and have no idea what that means (code missing?).

I was hoping for a simple step by step to get me going.

Can you or someone else provide me that?

the ... is actually part of the code, it's called the Spread Operator and it's just a simple way of referring to every item in a json object or array (so no code is missing, it's there on purpose)

so something like

const new_item = ({
    ...previous[item_index],
    ...changeset_item
  });

is creating a new object named new_item that has all of the contents of previous[item_index] followed by all of the contents of changeset_item

// if
previous[0] = { previous_key: "value" }
changeset_item = { change_key: "item value" }
// then
new_item = {
  previous_key: "value",
  change_key: "item value"
}

your usecase is a bit more complicated. what do you have set as the data source for table1?

I'm taking this with baby steps.
I have a blank table that I manually (type-in) into the cells with their values (a SQL database will be providing this data later).
I figure, if I can use the type-in data from table1, then a database provided data will be a snap to implement from there.

So let's just run with the manually entered data in the cells in table1.

Data is sitting there; I then go to another tab where table9 is. I want to select the I/O function, or the pin cavity values from table 1 (check) that are now populated from the data in table1.

My only issue now is that when I select one cell, I need to populate the other.

J1-2 funcA
J2-5 funcB
J3-99 funcC

From table1 above.

So, if I select J1-2, I want the I/O function column next to it to populate funcA in table9. Or if I select I/O Function value funcB, I want the pin cavity to cell to populate with J2-5 in table9.

How would I tie these together since I can't write directly to changesetArray?

Maybe a cascading drop-down behavior?

Thank you for your help!