About to go insane need some probably simple help

I am using the Accordion Component from the Market Place. I’m using a toggle button to show/hide the component. I have added a left side icon with the chevron still on the right side and in the content area of the dropdown I placed a container with a Delete and an Update button. When clicking the buttons it will trigger the toggle to close which seems to be the only way I could get the list to refresh without actually leaving the page and coming back.

The problem I’m having is that the only way either button will delete or update is using
( data.whatever.(0).id ) as the formula. But in doing so it will not delete/update the correct items.

I have my list sorted, so what it is doing is picking the index of what would be in that spot instead of what is showing. So my question is how can grab the correct item.

It’s driving me crazy. This shouldn’t be this difficult? I have been able to delete/update easily if I use any core list component. I’ve tried creating triggers to get outside the component. It still only works the way I’ve stated.

I created a Data Resource that works fine. The Accordion component uses a Data Adapter then you have to map it to the Data Resource but on the Delete Record properties you can’t access the Data Resource except using (data.whatever.(0).id) as I said above which will only delete the line index of what should have been in that spot had I not sorted the list.

Do I need to not use a Data Resource and just use the Data Adapter? or Maybe do an unsort delete resort on the fly?

Totally lost on this. :crazy_face:

This is the ever problem we all face as beginner working with lists (array).

Use the FIND_BY_KEY formula to work on the right item in your list.

I’ve tried that a few times and have never gotten it to work. I have been going around in circles so much I think I have tried every option in the program, The problems been no matter what choice I pick it tells me I can’t use Text, List, or Object and to make it worse a lot of times when it says you can’t do something it lets you do it anyways and works just fine.

1 Like

Can you show some variables schema and flow here so we get a better understanding?

I’m using ( GroupList ) as my on-device-storage name and
( Groups ) as my data variable name.

I have an App Variable as Object named ( addGroup_Value ) with 4 text properties
( title, id , type, content ).

I have the accordion1 inside a container called ( Accordion Container ) which allows me to show/hide with a toggle button.

The Accordion Component uses the Data Adapter called ( List resource ) with the same 4 properties (type, content, id, title) with ( title ) being the only thing required checked.
For the Private Data Variable the name is ( Items ) with key being ( items ).

So I drag a delete record block onto the top most spot for the component being Accordion1 and for properties it is already pre-selected with my list name
( GroupList ) there are not other choices. Below that is a spot for the ID. No matter what I put in there it says that I can’t use it since it’s an object, text or list and will result in my toast popup saying no data found to remove. But if I just use
( data.Groups[0].id ) it will delete something just not the correct item because it is sorted. It deletes what should have been in that spot if it had not been sorted.

I have an input box and a save button outside the list to create the list item with a value of (appvars.addGroup_Value.title ) The save button checks for an empty box then does a find ( FIND(data.Groups, item.title === appVars.AddGroup_Value.title ) to see if an item was already in the database which says I can’t do that but works just fine. It then goes on to create the new record if all is well. Using the App Variable ( AddGroup_Value ) for the assigned value it maps each property.

After a creation success Toast I do another App Variable block to reset the input box to empty then trigger toggle that will hide the list.

That’s basically it I can’t find the right formula to find the correct item to delete or update. I’m sure it is something stupid but I have been racking my brain trying to figure it out.

Hi,

What event are you binding the delete record to? I’d assume it’s the tap event of accordion1. In this case, you’ll have to find out the id or index or whatever identifying feature of the component you’re tapping. Data.groups[0].id aways takes the first ID that is in the underlying data array (indexing starts at zero). Now, unlike the basic list component, the accordion component doesn’t have output values on tap, which makes this a little more complicated. If you want to use the accordion regardless, you’ll have to edit it.

First, enter the component template editor by clicking on this icon:

Then, in its properties, add a new output value in the output values tab. The property key doesn’t really matter- I’ve chosen itemName. Then, go to the event tab and make an event that corresponds to this, for example, itemTapped. Then, back in the view tab, choose the item where you want to trigger this new event. In this case, that could be the List Item. Add the flow function “Set output value” and set our new output value and then assign it to value current.myField where myField is the identifier you want to use (it should be unique within the list). Finally, add the Trigger event node and choose “Component itemTapped” or whatever name you set.

Now, exit the component template editor. Add the Receive event node and choose “Component itemTapped”. Then, add your desired logic. The field you set current.myField should be available for use under formula → selected component properties. You can now use, for example, the FIND() formula function to find the correct field by its name.

Hope this helped. I know it’s a bit convoluted, as the accordion component wasn’t really designed with this functionality in mind.

I was real excited I thought this was really going to work. It seemed so logical. But it basically was just another way of doing what I had been doing. Everything worked just the way you explained it, but when I got to the last part of connecting a delete record block to the trigger it just will not let me put any thing in the ID field to cause it to Delete. I went right down the list of just about every option on the Formula choices.

If I make my own component everything works fine I can just put (repeated.currrent.id) in the ID field and it works no problem. I can click a button and Delete Puff it’s gone! - before you ask I want to know the answer so I can understand how everything works. I may be forced to just use my own but then I have a completely different issue.

I am trying to use Find() or Find_by_key() Maybe I’m using it in the wrong place or the wrong way. Does it need to be inside the component on the trigger side? or I’m assuming it must be on the outside with the receive trigger. It just doesn’t seem like the output is sending any data to the receive trigger. It is receiving the trigger since my toast is popping up with a message of nothing to delete.

Given all the info above from both of us how would you write out the formula for the find - FIND_BY_KEY(list, key, value)???

Hi,

The ID field should have the ID of the record you’re trying to remove, not an entire object. If you set up the output values as described in my previous post, this could be self.myField. If you use FIND(myList, myProperty, self.myField), you’ll get the Object that you’re currently tapping - in this case, you’d have to specify the field again FIND_BY_KEY(myList, myProperty, self.myField).myField, which is redundant. However, if the actual field you want to use here is not myField, FIND functions are the way to fetch them as you can access all properties in the object, e.g. FIND_BY_KEY(myList, myProperty, self.myField).myOtherField.

Note that the self.id that’s available in the Selected component properties submenu of the formula editor refers to the component’s ID and shouldn’t be used for this task.

You can also watch the onboarding video tutorial Data - Show single data record (starting around 1:20) for a demonstration of a workflow with component output values.

Ok, so now I have made the output block go to the trigger block then to the receive trigger block. But I still can not delete the Item. But I know the value is getting sent because I used a toast message after the receive trigger and I get my data. I can use a bunch of different formulas and I get my data returned.

So lets say I have a list of the alphabet. I click the delete button on list item “A” and it sends the value to the output then the trigger sends it to the receive trigger. and the toast message pops up with the letter “A” problem is it’s the letter “A” just a static “A” I can not get a delete record block to recognize it as a list item. It seems like it has something to do with the way the accordion uses a data adapter where my list is just a data resource and it maps fine one direction but the other?

Do all of the list components work as weird as the accordion component. I just can’t believe that anyone would not want to delete or update an item in a list. Those are common functions that should be the easiest thing to achieve! I don’t have to use the accordion component if there is another similar one that works better.

In any case I am completely baffled!!! I will probably be up late every night until I figure this out. I just can’t believe it doesn’t work.

Hi,

Not all the list components work like this. If you use a repeating list item, you can directly use the “current.id” property. The basic list component, which is more meant for this kind of task, has a built-in output as well. If you’ve already set the output value to an ID, there should be no big difference.

First, check that your accordion has the Refresh data? property set to True, otherwise the users need to refresh the page to see the changes.

Next, see which field the Delete record flow function wants. In this case, I’ve configured an on-device data storage, which always sets the identifying field to ID. This means you have to output the ID of the item from the accordion. It won’t identify the item by its name, for example - although you could use some formula function like FIND_BY_KEY(myList, "name", current.name).id to get the ID of an item with the outputted name.

If you’re using some other data resource, using e.g. REST API direct integration, the Delete Record method in the data tab has to be enabled and configured. Whatever query parameter you give to the method will be reflected in the Delete record flow function, so choose an identifier that fits your needs.

Ok I have given up on the Accordion Component. All other components that I have tried work fine as well as have better options to use in them.

But now I have a new issue that is possibly a bug and want to see if anyone knows before I spend hours trying to figure it out.

The problem is I am using a (combo box component) that gets it’s data from an Object , list, text.

In Properties List of Object I have:
MAP(data.MyNotes, { value: LOOKUP(item, “Group”), id: LOOKUP(item, “id”) })

For Input Value:
I have my app variable: appVars.My_Notes.groups

So when I click my save button the input value is added to the list on the previous page and works great all list items are in their respective groups.

But, When I come back to my combo box I have many duplicates since each group name even though it may have the same name it is still part of each list item that contains it.

So I created a data variable:
UNIQUE_BY_KEY(data.MyNotes, “Group”)

I assumed the most logically place for this formula to go should have been In (Properties List of Object) where I have the MAP formula but I could not get it to go in there correctly. So I created the data variable.

So everything works as expected except it will randomly lose the ability to use UNIQUE_BY_KEY(data.MyNotes, “Group”) and reverts back to showing duplicates.

The first time doing it works fine but if I clear the input box click the down arrow then clicking the arrow a 2nd time, instead of closing it changes to show duplicates. Click it again and it will probably go back to working.

Also note that on Android it will rarely work at all. You may have to click the arrow multiple times before it will open.

I have attached the variable to just about every place I can but it still does it. So either there is a bug or I’m missing the one central place to use UNIQUE_BY_KEY(data.MyNotes, “Group”)

Totally baffled at this point?

As a side note is the Opera Browser compatible with the forum. Every time I use this page It freezes up everything on the browser but this page and I have to (cntrl-alt-del) then cancel to fix it?

In case anyone is wondering? I solved my issue of duplicates in the dropdown field.

  1. I created a Page Variable called (NoDups)

  2. For the ComboBox’s (Properties Option Block) I mapped it to the Page Variable’s (Field and ID.)

  3. In the Page Layout (the upper most line of the Tree). I used a Receive Trigger attached to a (Set Variable Block) that Mapped the variable to my data. Then attached a 2nd (Set Variable Block) to the 1st one using the (Unique_By_Key) Formula on the Page Variable.

  4. Then going into the (Component Editor) I created a Trigger pointing to the Recieve Trigger (Give your Triggers/Receive Triggers Names in the Advanced Properties and it will be easier to find and connect them.) I placed the Trigger in the ComboBox 1 (upper most Tree Level) connected to the (Page Mounted Event) and I also placed a Trigger on the (Component Tap) of the Chevron and the Chevron’s Container.
    NOTE- The last two Triggers were probably unnecessary.

  5. Eureka! it worked with no reverting back to duplicates as stated in previous message.

Although I have to click the Chevron twice the first time I enter the page on Web Preview not sure why. It seems like some kind of BUG that needs to get squashed! If anyone knows how to stop that from happing I would really be a happy camper. If not a bug I’m guessing it might have something to do with a built in delay but it works perfect after the first click?

Unfortunately on Android Preview clicking a drop down works when if feels like it. One day it works the next it doesn’t. I usually have to click it 20 times to make the dropdown open. Not to mention I can use the Web Preview on Android and it works fine so it’s not the Cell Phone it is the Android Preview!

Now I just have 3 more major hurdles to overcome. :crazy_face:

1 Like