251
Views
16
Comments
Solved
How to remove item from list

Hello,

I have a list variable with store the name and email.

I want to remove the item from the list, so I am using List Remove to remove the item.

To get ID for item I used aggregate to get the ItemID and used server action to delete the Item. 

Whenever I try to remove it doesn't delete the selected item.


I have attached the AOP file.In this I have a list of subjects. I added subjects directly from database.

While removing the subject, suppose I have 4 subject A,B,C,D and I try to remove D then C will be removed instead of D.

Click of minus icon to remove subject and refresh the page.

Thanks in advance

Student_Details.oap
2023-06-23 06-41-28
Bandaru Mahesh
Solution

Hi @Raj1010 

I have implemented the logic to remove item from the list. I just updated the logic based on your OAP. Iam attaching the OML. Please check and let me know if you have any issues.


Regards

Mahesh


Student_Details.oml
UserImage.jpg
Raj1010

Thanks, this works perfect

2026-03-12 06-20-48
KUNDAN CHAUHAN
Champion

Hi @Raj1010 ,

Please share your OML if possible.

Regards,

Kundan Chauhan

UserImage.jpg
Raj1010

I have attached it

UserImage.jpg
Vitheya sudesan

Hi Raj,

Please follow the below steps to delete a particular item from a list variable,

1. Use listIndexOf action to know the exact position of an item from the list variable.

2. From the listindexOf action, you will receive an position of the item in the list variable.

3. Use that position result in the list remove action to delete the record.


If any clarification, let me know.


thank you.

UserImage.jpg
Raj1010

It is not removing the selected item. If I try to remove A it will remove B. 

2025-08-03 07-20-35
Mythily - EONE

Hi,

You mentioned that you had used aggregate to id right.

Make sure that you pass name and email as filter to the condition, and use the ID in DELETE action.

If possible you can share the error message that you get when you delete the message.

Thanks

2020-09-15 13-07-23
Kilian Hekhuis
 
MVP

Hi Raj,

I'm not sure I understand the connection between the list and the database. Removing an item from a list is something altogether different from removing an item in the database.

What is it you are trying to achieve, and what exactly doesn't work as expected?

UserImage.jpg
Raj1010

I have used List variable to get all Item from aggregate.
GetItem.List  -> AppendList  in UI

Now I want to remove the item from the List. I have attached the aop file you can have a look

2024-05-30 10-12-48
Anushka singh

Hello @raj1010

Add a local variable to store the selected SubjectID. On the button/icon click, set the SelectedSubjectId. Create a server action to delete the subject using the SelectedSubjectId. After deletion, refresh the aggregate to update the list 

i hope it helps!

UserImage.jpg
Raj1010

Hello Anushka,

I am not using ID. I am using name then I am getting ID based on name selected

Now, if I try to remove subject A  with ID 7 then some other value is getting removed and while debugging I can see selected item is not A its always something else.

2024-05-30 10-12-48
Anushka singh

ok raj

step by step:

Define a structure for subjects with Name and ID.

Create local variables to store the selected subject name and the list of subjects .Bind the dropdown or list widget to SelectedSubjectName 

Create a server action RemoveSubjectByName that takes SelectedSubjectName as an input.

In this action, retrieve the ID based on the Name and then delete the subject using the retrieved ID 

Add a button to trigger the removal of the selected subject.

Bind the button's action to the RemoveSubjectByName server action.Ensure the subject list is refreshed after the removal action to reflect the changes 

i hope it helps!

UserImage.jpg
Raj1010

I have added id in the list and in the remove server action i passed  List.current.id still it delete some random value.

2023-06-23 06-41-28
Bandaru Mahesh

Hi @Raj1010,

I tried simulating your problem, here I am attaching sample OML. Hope It will help you. 



Regards

Mahesh

RemoveItemFromList.oml
UserImage.jpg
Raj1010

Hi Mahesh,

After adding item to list I am also adding it into the table. So basically it will check for duplicate value in table if its unique it will add or display error. Adding logic works fine.

While removing, I can remove from List but when I pass Id  in server action to  delete it from table some random item is deleted not the selected one.

2023-06-23 06-41-28
Bandaru Mahesh
Solution

Hi @Raj1010 

I have implemented the logic to remove item from the list. I just updated the logic based on your OAP. Iam attaching the OML. Please check and let me know if you have any issues.


Regards

Mahesh


Student_Details.oml
UserImage.jpg
Raj1010

Thanks, this works perfect

2025-04-22 05-54-18
Shashi Kant Shukla

Hi Raj,

In order to delete item from a list using List Remove  you have to pass index of list item. So if you want to delete a item and you have id of that item, them you have to write the logic to get the index of that id in the list where you want to delete then you can easily delete it.


Regards

Shashi Kant Shukla

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.