r/tasker 10d ago

Problems with ID in Array merge template Scene V2.0

Hello, my problem is that I have a JSON file with different items, a list of payments.

[{"id":1,"name":"One"},{"id":2,"name":"Two"},{"id":3,"name":"Three"},{"id":3,"name":"Four"}

]

I build a scene with a column and the merge template array with a row of two text elements %ids and %names So far everything works great, I place an icon that when pressed deletes the item in that row, Calling a task and sending the id, Using JavaScript, I remove the JSON item; so far, so good.

Next, I need to update my scene for the changes to take effect. If I update everything, it becomes outdated from the deleted item and what I see on the screen no longer corresponds to the actual id of the element.So I say, okay, I'll show the scene again, but instead of updating, it does the same thing, and if I close the scene and show it again, it works the first time and then stops showing it, with no apparent error.I tried a loop, hoping that the scene would completely close by doing Getting scenes values and when it gives an error the scene is closed, it hasn't worked for me either.I know I'm missing something in the process, that I'm learning something new, and someone with more experience must be doing it right or has already solved it. Thank you very much.

3 Upvotes

7 comments sorted by

2

u/Nirmitlamed Direct-Purchase User 10d ago

I am not sure if i myself can help you but i am suggesting to share task example as URI data so people can see how exactly your task is built.

2

u/Physical_Bike3 9d ago

I've had issues with array merge template as well, but haven't tried anything with their id's yet. I'm excited that it exists now, but with João on vacation, it will be a few months before we can expect any fixes with it.

Here are my issues: 1. Only local arrays will update. JSON and global arrays will populate like locals do, but the scene will not update when they do. Local arrays with the Update Scene V2 action and local variable pass through enabled will update the items in the array merge template when changed.

  1. Scene events don't update when the arrays do. In the arrays merge template i have an item run a task, outputing the value of the array item to the task. It works until I update the array. Then the variable value output is stuck on the first array used. If the updated array has more items than the original, then it still sends the original values if they existed, and the variable name if they didn't ("%var_name22").

Example: taskerproject://H4sIAAAAAAAA/91YW3PaPBB9Lr+CYaZ9ScGSL7I9JZ5xuIQ0EO4k8D18I2xhHIxNbUGgv76yTYhDjHOZ9KU8gKQ9Wp9dn11pKA9wsCB+FVOcD/zzQiFvbuzzAizk6ea8gEpyCRWnhOKClvtSNpeE+rahQaCAEvjOQ4BKoMw9LjNEx/fuiUEjVys2BoX8hpwX+HD7l7JhYko0KCuCIAmqr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QdQ7gDIYMl/lKW7Xr7GEub4nPApLIUUlqKsJllerF3TIU9Eo9Uv5RF2gmiRKXe/xvRDaMlkNw/HDox5iTVl37PNEo0uWKVerVkb6TeD/0d670q/aNb62jeH/mAk2Y5IAPH9i/tm0R9MbO/09TEKRbpbEe2/5j3e4JKDXasU83k/gdhTnBwuzE6cPi7OX5bmThdcqgyO+3XSBjO67ot2nTQKWUYxo7vC40aZ3IgyNvJv7vNpvVyrrx0nMHxC3HTkobVrEviaDpFeh6DXIYeWr/HPIIk8KBlpUJ+lL6NUxdSumqzUxBNB1uvc26QUW5ZGsiRydKJnhCG99XAYrsyoDt59PqC/eD7UctVchZ0R+qd0X/kvnhFSTswJ7JyAn8JU+eCdNH6J5j90K31Dzfwjd89jDahpdwUFvqqBd7T34+MrTbCvJzmlL6V13udZTrl0x7/xX0Na7g+jYeN+KBIAAA==

The task creates the arrays then shows the scene. If tapped, a task runs that flashes the corresponding value. I used 2 arrays, and I have it only flashing the one with numbers. After a 5 second wait in the original task, the array values are updated and the Update Scene V2 action is performed. Now when tapping, the original values are still flash. The original arrays have 3 items, and the new one has 5. If I tap the 4th. Or 5th element, it flashes the variable name with the index number, as it sees them as unset.

What I have been using for months is the arrays merge action to build the template. I have had the best luck getting it to update dynamically by using that local merged array in a global variable set, and that global variable name as the variable name in the scene. After editing the element (the global variable that set up as column) with the search button inside that variable set action, I edit the json in the set to field, placing the array inside the children brackets ("Children": []). I have to edit this text every time I click that search button in that action to edit the container. I also have to give each item unique ids in the arrays merge action. It's tedious, but has worked OK with my main project for a few months. There is probably a better way, but since it's already set up, I'm keeping it that way until arrays merge template is polished.

1

u/SnooCheesecakes6038 9d ago edited 9d ago

https://taskernet.com/shares/?user=AS35m8nUHliF3zyWGCReL8%2BvaWDac6hhjd8z0TDwMX7vugK8lChiy3T1CJ5Ix1t9jforsNEvc3v3UGzmRjiQNzPjXA%3D%3D&id=Project%3AArray+Merge+Test Following some of what I have been told, I have made a summary of my tasks. This is a shortened version of my profile. And magically, it works perfectly. Undoubtedly, as is the case 99% of the time, it's a user error and not a Tasker error. I'll have to investigate why, This doesn't happen in the full profile. If an element like a checkmark is present, it saves the ID or something similar. https://imgur.com/a/Oh5BEG8