cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Kathryn_Marie
Level: Powered On

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
Kathryn_Marie
Level: Powered On

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

Kathryn_Marie
Level: Powered On

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.

Kathryn_Marie
Level: Powered On

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

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

Kathryn_Marie
Level: Powered On

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 😕

Kathryn_Marie
Level: Powered On

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

Community Support Team
Community Support Team

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.
Kathryn_Marie
Level: Powered On

Re: Remove item based on ID

Yep, and done. Thanks for your help.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (4,732)