How to Edit specific data in a repeated list

Let’s say I have a repeated list of objects called MyListObjects[{…}] , and i tap it, and In the tap event i get this object’s data (current.name, current.likes, current.whatever, etc…) . How would I go about changing these values?

For example let’s say I have a “Like” icon that the user can click on in these repeated containers. How would I increase the value of current.likes by 1 when the user does this? Assuming I clicked on index 7, so “current” would actually represent MyListObjects[7] … I need to be able to edit directly the object values at index 7 of the array (list). Im not sure how this is done.

Thiiiiis is something that is currently really really hard or impossible, and will be made a lot easier with 2.X :smiley: One of the reasons why moving from 1.X to 2.X is such a big deal.

2 Likes

Lol… Ok now i feel much better about myself :smile: I thought it might be something so ridiculously easy but i was complicating it so much that i couldnt figure it out. Good to know that it’s actually hard to do!

I know this is wrong (it didnt work), but Im thinking to accomplish what I want that it would involve a formula that does “Something” along the lines of this:

MAP(pageVars.MyListObjects, IF(item.id === current.id, SET_KEY(item, “Likes”, current.Likes + 1), item))

Someone more expert in scripting please jump in and fix this to work… :slight_smile:

So this is actually what it needs to do:

SET_KEY(FIND(pageVars.PAGE_MessageArray, item.id == current.id), “Likes”, LOOKUP(current, “Likes”) + 1)

This increments Likes ÷1 at the current index

I’m not sure how to do this currently, except through page variables and searching with the current.id from there if that’s working for you, but what I do know is that with the upcoming changes, there will be a logic flow function to set a repeated item’s value, and formulas to access all sorts of data about the repeated item, as shown below. (2.X upcoming features that are in internal testing currently:)

Screenshot 2020-10-12 at 9.15.42

Screenshot 2020-10-12 at 9.10.18

If you can wait for these additions, I would suggest you do, but you might find a way to get it to work as is – the problem will probably be that the list won’t refresh in the UI even though it has changed in the backend, unless you set the list again. By setting the list again, I mean that you repeat the list via e.g. page variable, and on the click of the button you set the page variable. (This should become unnecessary in the new 2.X runtime)

3 Likes

That looks like it would do what i wanted waaaaay easier. I will likely change what ive done to use that method.

Yep, that’s exactly why we are doing these changes :grin: Hopefully by end of this month this will be out as stable!

When you say “set the list” so the UI would update this is what i had to do - i had to copy the updated data into a temp object variable. Then remove the current list item with WITHOUT_ITEM. Then add the updated temp object back to the array with WITH_ITEM. Then i write the updated list back to the database

So youre saying with the new logic i wont have to do all that to update the list array so it shows correctly in the repeated UI

Yeah with the new client the way the UI refreshes is built differently, and all this setting should no longer be required (we are quite tired of it ourselves :D)

1 Like

@Mevi, do we already have a date for this?

To my knowledge, we are hoping to get 2.X into stable this or next week!

Hello everyone. It seems that I want to do the same as John, however I really do know how to use “Set repeated item value”. It is because nowadays its accept only one parameter that I supposed that is the field that I want to change. For example, current.fieldtochange. There is another parameter but this has a message “Obsolate”. It seems to be the field that I can use to provide the value to change. Can someone helps me in how to use it? My field is a text, it is bound directly to a button and I need a formula to decide the next value.

Yes I want to know why the ‘Set Repeated Item Value’ flow function says ‘Obsolete’ for the Value. There is no way to set a Value!?

Interesting, I have never seen this flow function before :smiley:

First of all, check that you are using this flow function inside the Container that you repeat. So e.g. on the logic canvas of a button that is inside the repeated container, like so:

Screenshot 2021-04-16 at 11.21.55 (Container named Repeated Container for clarity)

On the button’s logic canvas, you should be able to access current. Note that under “Repeated”, select static text type to select the correct value from current. Then you can set the value with a formula, for example.

Screenshot 2021-04-16 at 11.22.39

EDIT: Apparently there’s an UI issue unless you have beta enabled for the app. This will get fixed in the next platform release.

1 Like

This doesn’t work is the repeated list is bound by a formula?

Yes, it doesn’t work if the repeated list is bound to a formula… It has to be bound to a variable… In my case, the repeated list can’t be bound to a variable, it has to be bound to a formula, and I’m working hard to try to find a solution. Is there anybody that can help me or share some clues?

Ok. Mine is a formula. Would get back if I crack it!

1 Like

Great @Kaushik_Bhattacharya!
@JOHN_WORSHAM, did you face the same problem, or did you finally manage with a repeat bound to a variable?

As long as the flow function “Set repeated item value” works when bound to a page variable, I let the “Repeat with” bound to a formula for my first 3 columns and I did a separate “Repeat with” bound to a page variable for my 4th column. I then added a “Set repeated item value” flow function when tapping icons of my 4th column and it works. But now the problem is that my 4th column is not anymore linked to my first 3 columns, and I can’t get the same number of icons in my 4th column…

I got mine to work on a repeated Page variable

1 Like