cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Responsive Resident
Responsive Resident

Removing record if it matches a condition

I have an app that keeps track of inventory available for a particular job. I use 2 SP lists - one to track the jobs and a second to track the list of items for that job as each job may have anywhere from 2 to 25 or 30 items. When the items are sent out, all the items may not go out, so I need to remove specific items from that list. I have the items being scanned into a collection and I thought I was testing the removal correctly, but all items are always removed anytime I run the code. The collection is "col_Items", and var_JobNumber is the job number.

 

ForAll(col_Items, RemoveIf(TrimReturn_Items, ItemNumber=ItemNumber And var_JobNumber=JobNumber));

Obviously the logic is wrong, but I'm not seeing where.

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Super User II
Super User II

Re: Removing record if it matches a condition

Hi,

 

You need to disambiguate the Item number like [@Datasource].ItemNumber as currently it's looking at your collection and checking if ItemNumber=ItemNumber (and they are both referring to the same thing so its Always true, like checking if 1=1)

 

ForAll(
       col_Items,
       RemoveIf(
                TrimReturn_Items,
                ItemNumber=[@OtherDataSource].ItemNumber
                &&
                var_JobNumber=JobNumber
       )
);

 

Let me know if that helps or if you run into any other issues,

 

Cheers,

Sancho

 


@iAm_ManCat

Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


View solution in original post

Highlighted
Responsive Resident
Responsive Resident

Re: Removing record if it matches a condition

So the disambiguation was the issue - Powerapps just wanted me to do it the other way!

This code works:

ForAll(
     col_Items, RemoveIf(TrimReturn_Items, TrimReturn_Items[@ItemNumber] = col_Items[@ItemNumber]
     And
     var_JobNumber=JobNumber));

View solution in original post

4 REPLIES 4
Highlighted
Super User II
Super User II

Re: Removing record if it matches a condition

Hi,

 

You need to disambiguate the Item number like [@Datasource].ItemNumber as currently it's looking at your collection and checking if ItemNumber=ItemNumber (and they are both referring to the same thing so its Always true, like checking if 1=1)

 

ForAll(
       col_Items,
       RemoveIf(
                TrimReturn_Items,
                ItemNumber=[@OtherDataSource].ItemNumber
                &&
                var_JobNumber=JobNumber
       )
);

 

Let me know if that helps or if you run into any other issues,

 

Cheers,

Sancho

 


@iAm_ManCat

Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


View solution in original post

Highlighted
Responsive Resident
Responsive Resident

Re: Removing record if it matches a condition

I had tried that, but I get an "Invalid argument type" error

Highlighted
Super User II
Super User II

Re: Removing record if it matches a condition

Could you please post a screenshot while hovering over the error area so we can see the details? That will help determine where the issue is 🙂


@iAm_ManCat

Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Highlighted
Responsive Resident
Responsive Resident

Re: Removing record if it matches a condition

So the disambiguation was the issue - Powerapps just wanted me to do it the other way!

This code works:

ForAll(
     col_Items, RemoveIf(TrimReturn_Items, TrimReturn_Items[@ItemNumber] = col_Items[@ItemNumber]
     And
     var_JobNumber=JobNumber));

View solution in original post

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Tech Marathon

Maratón de Soluciones de Negocio Microsoft

Una semana de contenido con +100 sesiones educativas, consultorios, +10 workshops Premium, Hackaton, EXPO, Networking Hall y mucho más!

Top Solution Authors
Top Kudoed Authors
Users online (6,016)