How to update a value in an Array displayed via Table Widget

I’m creating a list of serial numbers with associated characteristics and displaying them in a Table widget. Once they are created, an operator has to manually enter data in to populate one of the fields called the ESN. I can’t figure out how to update a field in the table.

I have a linked variable, but updating that doesn’t update the array. If I could tell which index was selected, I could pop that out and pop it back in, but I can’t figure out how to tell which index of the array is selected


Hi @Gary, thanks for the question. Sorry to have to ask a basic question: can you really quickly confirm for me that the datasource for this table is an array of objects and not a Tulip table? It would look like the screenshot below.

Screenshot 2023-04-07 at 2.15.30 PM

Here is a photo of the data source:

@Gary, I’m noticing the variable name is “list_from_flexo”. Is this variable coming from a connector function?

@Gary, I found a hacky solution, let me know if this works for you!

The basic technique we’re using here is that we’re feeding a list of ESNs through the looping widget to count how many items there are in the list before we hit our selected ESN. That count is our index position.

Here’s the breakdown:

  1. Make sure there’s a linked placeholder variable assigned for a selected row in your table.
  2. use the MAPTEXTTOLIST() function to pull a list of ESNs from the object list
  3. Run that array of ESNs through the looping widget to calculate the index position
  4. (here’s the hacky part) Push a new object onto the end of the original object array
  5. Swap the object at the end of the array with the object at the calculated index position, and then delete the obsolete object from the end of the array

Here’s the process:

1. Make sure your table has a linked variable for selected rows

2. Add a trigger to your interactive table to store the ESN value to a placeholder variable

3. On a separate button, use the MAPTEXTTOLIST() expression to create an array of ESN values from your original object list

4a. Feed your new array into the looping widget

**4b. The Looping logic should look as follows **

What you’re doing here is incrementing a count every time a value IS NOT your desired ESN. When the looper encounters the correct ESN, it saves that value to another variable to prevent the list from incrementing through n.

Note that the final if/else condition is accounting for the scenario when your desired value is the first in the list.

5. Update the data by pushing the linked variable onto the end of the original object list, and then swapping that variable with the object at the desired index position. Delete the old record from the end of the object list

@Gary @John There is another way to accomplish this without looping.

You could do something like this (verified as working). Basically, just pull out the field that you want to use for search, provided they are all unique, and map it to another array. Then find your value in that array and get its index. Then save your changes back into the original array at the index.

1 Like

@Gary worth noting that this can be compressed into a single trigger action if you’d prefer to keep it tight

Thanks @John and @freedman, I’ll give those a try