cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

Remove item based on ID

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Helper III
Helper III

Re: Remove item based on ID

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)));

View solution in original post

8 REPLIES 8
Highlighted
Super User
Super User

Re: Remove item based on ID

@Kathryn_Marie 

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."

Highlighted
Helper III
Helper III

Re: Remove item based on ID

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.

Highlighted
Helper III
Helper III

Re: Remove item based on ID

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 )));

Highlighted
Super User
Super User

Re: Remove item based on ID

@Kathryn_Marie 

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."

Highlighted
Helper III
Helper III

Re: Remove item based on ID

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 😕

Highlighted
Helper III
Helper III

Re: Remove item based on ID

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)));

View solution in original post

Highlighted
Community Support
Community Support

Re: Remove item based on ID

Hi @Kathryn_Marie ,

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 Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Helper III
Helper III

Re: Remove item based on ID

Yep, and done. Thanks for your help.

Helpful resources

Announcements
secondImage

New Return to Workplace

Reopen responsibly, monitor intelligently, and protect continuously with solutions for a safer work environment.

August 2020 CYST Challenge

Check out the winners of the recent 'Can You Solve These?' community challenge!

Experience what’s next for Power Apps

Join us for an in-depth look at the new Power Apps features and capabilities at the free Microsoft Business Applications Launch Event.

Check this Out

Helpful information

Featuring samples like Return to the Workplace and Emergency Response Applications

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Users online (3,430)