web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Remove item based on ID
Power Apps
Answered

Remove item based on ID

(0) ShareShare
ReportReport
Posted on by

Hi All,

 

I've recently been updating my app so I am using ID's and lookup tables, which means that if a name changes, it flows through to everything in the app. So I have a remove function, and now that the table I'm removing from has an ID instead of the name I select in the listbox to remove, I'm having trouble to get the code to work.

 

Basically I select an item in a list box, click a button, and the item is removed from a table. However the item I select is the name of the item, and the item in the table to remove is the ID of that name. Being that there could be multiple selections, I have used a collection.

 

ClearCollect(ItemCollect, {item: ListBox4.SelectedItemsText.Value});

ForAll(ItemCollect,
RemoveIf(Mapping, LookUp(Items, crb20_item = item, crb20_item_id)));

I'll get my head around the lookups soon I hope!

 

Thanks

 

Categories:
I have the same question (0)
  • mdevaney Profile Picture
    29,989 Moderator on at

    @Anonymous 

    I have chosen to replace your LOOKUP function with a comparison statement instead. It removes allmatching records from Mapping where crb20_item is equal to item in the ItemCollect collection.  Is this what you to wanted to achieve?

    ClearCollect(
     ItemCollect,
     {item: ListBox4.SelectedItemsText.Value}
    );
    ForAll(
     ItemCollect,
     RemoveIf(
     Mapping,
     crb20_item = item[@ItemCollect]
     )
    );

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • Community Power Platform Member Profile Picture
    on at

    I need to use the lookup, because the item in the listbox is a name, and what is in the mapping table is an ID, so need to match the name in the lookup, with the ID in the mapping table, and remove the matching record.

  • Community Power Platform Member Profile Picture
    on at

    This i'm closer with this, but getting invalid argument type:

     

    ClearCollect(ItemCollect, {item: ListBox4.SelectedItemsText.Value});

    ForAll(ItemCollect,
    RemoveIf(Mapping, crb20_item = LookUp(Items, crb20_item_id = item, crb20_item_id )));

  • mdevaney Profile Picture
    29,989 Moderator on at

    @Anonymous 

    Where in your formula are you getting an invalid argument error?

     

     

     

    Also, I'm gonna give this another shot revising my previous formula which was not making any sense...

     

    ClearCollect(
     ItemCollect,
     ListBox4.SelectedItemsText
    );
    ForAll(
     ItemCollect,
     RemoveIf(
     Mapping,
     crb20_item = ItemCollect[@Value]
     )
    );

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • Community Power Platform Member Profile Picture
    on at

    This bit gives the invalid argument error:

     

    learCollect(ItemCollect, {item: ListBox4.SelectedItemsText.Value});

    ForAll(ItemCollect,
    RemoveIf(Mapping,
    crb20_item = LookUp(Items, crb20_item = ItemCollect.item, crb20_item_id
    )));

     

    In your example, when you have:

     RemoveIf(
     Mapping,
     crb20_item = ItemCollect[@Value]
     )

     crb20_item in the mapping table is an ID. The selection from the listbox is a name, so I'm not sure how that can work 😕

  • Verified answer
    Community Power Platform Member Profile Picture
    on at

    Got it 🙂

     

    Clear(ItemCollect);

    ForAll(ListBox4.SelectedItems,
    Collect(ItemCollect, {
    item: ListBox4.Selected.crb20_item
    }));

    ForAll(ItemCollect,
    RemoveIf(Mapping, crb20_item =
    LookUp(Items, crb20_item = item, crb20_item_id)));

  • v-yutliu-msft Profile Picture
    on at

    Hi @Anonymous ,

    Do you mean that you've solved your problem?

    Do you have any other problems?

    If you do not have any other problem, could you change your issue's status to Answered.

    Thanks!

     

     

    Best regards,

  • Community Power Platform Member Profile Picture
    on at

    Yep, and done. Thanks for your help.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 721 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard