Add Value instead of Set Value?

I have a user-specific text data-field which I populate with a choice component. The choice is set to allow multiple. This creates a list of values such as “1234,5678,91011”.

I am also looking to populate this user-specific text data-field via a button on detail pages. This works with a single value by using the “Set Value” action. But how can I change this to an “Add Value” action so multiple values can be selected via clicking the button on multiple detail pages? Currently clicking the button on another page replaces the existing value.

  • Create a template column that takes the existing value and adds a comma followed by the value to be added.
  • Use your action to do Set Column Values, but use the Template column as the new value.

Would this require two value columns and a template column?

Not sure how else to get the existing and next selected value in the template.

No, just the template column.

  • You already have the existing value in the target column, eg: “1234,5678,91011”
  • And you have the value in the Single Value column that you want to add.

The template just combines the two values above.

I see, I dont think this would work for adding multiple values.
I understand it would work for adding a single value to an existing set of values.
I’m looking for a sort of add to cart function. So I can go to various detail pages and click a button to add the reference number to a column as a list.

Just revisiting your original question:

I read that as saying that each time you click the button, it would add the associated item to the list.
But are you saying that you would want to select multiple items across several pages first, and then have a button that would add them all at once?

Either way, personally I would probably approach this a different way. I would use a single row Helper Table for my Cart, and add/remove items into an array column (Multiple Files column) via a Single Value->Whole Row column.

Thank Darren,
Please could you share some more details on the setup of the helper table?

It’s kind of difficult, because I have no idea what your table structure looks like, but the general idea would be as follows:

  • Single Row “Cart” table, containing a User Specific Multiple Files column
  • In your Products table (or whatever it’s called), you’d need the following columns:
    – Single Value->First->Whole row column that targets the Cart table. This allows you to Set Column values in the Cart table from the Product table.
    – Single Value->First that fetches the Multiple Files column from the Cart table (this gives you the current contents of the Cart)
    – Make Array column: combines the previous column with the current rows ItemID (use this to add items to the cart)
    – Remove Element column: removes the current rows ItemID from the Cart array (use this to remove items from the Cart)
  • Adding and Removing items is a simple Set Column Values action, operating on the User Specific column in the Cart table via the first Single Value column: using the value of the Make Array column to add to the Cart, and the value of the Remove Element column to remove from the Cart.
  • To clear the Cart, it’s simply a matter of clearing the value in the same column.
2 Likes

Works perfectly!
Thanks Darren

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.