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

check if an email exists in a collection

This is complicated since I only need the emails of a respective ID

I will give you the example

I make a filter that returns several emails (I need it)

 

Filter (
"Training of participants",
IdTraining = Value (lblIdTraining.Text)
).Mail

 


this returns me


exaplemail1@mail.com
exaplemail2@mail.com
exaplemail3@mail.com

so I have a screen in powerapps where I manually register people in a collection

 

Collect (
List,
{
QR Name: DataManual.name,
EmailQR: DataManual.mail,
PositionQR: DataManual.position,
DepartmentQR: DataManual.department,
AreaQR: DataManual.area
}
)

 

the name, email, position, department and area are stored in the collection

Now I want to know if there is an email from those I brought in the previous filter in collection


i'm dealing with

 

Filter (
"Training of participants",
IdTraining = Value (lblIdTraining.Text)
).Mail in List.EmailQR

 

it gives me the error

cannot use table values ​​in this context

I guess it's because they are a set of elements.

1 ACCEPTED SOLUTION

Accepted Solutions
EricLott
Level 10

Re: check if an email exists in a collection

Try this:

IsBlank(Filter("Training of participants",
IdTraining = Value(lblIdTraining.Text),
Mail in List.EmailQR
))

View solution in original post

7 REPLIES 7
EricLott
Level 10

Re: check if an email exists in a collection

Try this:

IsBlank(Filter("Training of participants",
IdTraining = Value(lblIdTraining.Text),
Mail in List.EmailQR
))

View solution in original post

King
Level: Powered On

Re: check if an email exists in a collection

Hi @EricLott thanks for answering

 

This does not work if I put it in an If condition

 

If (
    IsBlank (
        Filter (
            'Training participants',
            IdTraining= Value (lblIdTraining.Text),
            Mail in List.EmailQR
        )
    ),
    Patch (
        'Training participants',
        First (
            Filter (
                'Training participants',
                IdTraining = Value (lblIdTraining.Text)
            )
        ),
        {Status: "Didn't Present"}
    )
)

 

 

dynamicsedge
Level 10

Re: check if an email exists in a collection

@King 

 

If needs boolean. Patch doesn't return a Boolean

 

Instead, 

 

  1. Set a boolean variable
  2. in If statement, say Set(YourVar,true)
  3. Make Timer Control, set visible to false, set auto start to false, set repeat to false, and set Start to YourVar
  4. Set duration of timer to 1 (1 millisecond) to be quick as possible - or you can set it a bit higher if you want like 100 or so.
  5. In Timer Onstart, move your Patch there
  6. In Timer Onend, set the variable to false again Set(YourVar,false) so timer can be reused.
  7. This should help in these kinds of cases.
dynamicsedge
Level 10

Re: check if an email exists in a collection

@King 

 

Or, try a simpler alternative to Timer (maybe it works):

 

Wrap the whole Patch in a Boolean returning function such as IsBlank, etc. 

EricLott
Level 10

Re: check if an email exists in a collection

@King 

Okay, let me take a step back. Let's build a new collection based off of these two data sets. We'll do that by using AddColumns() to loop through one to build on to the other.

 

ClearCollect(PresentedResultSet,
AddColumns(
     List,
     "Presented",
     !IsBlank(LookUp(Filter('Training of participants',IdTraining = Value(lblIdTraining.Text)),EmailQR=Mail,EmailQR))
))

 

Then, we can test against this new collection called PresentedResultSet.

 

Filter(PresentedResultSet,Presented=true)

 

Meaning your last Patch() example should look like this,

 

ForAll(PresentedResultSet,If(Presented=false,
    Patch (
        'Training participants',
        First (
            Filter (
                'Training participants',
                IdTraining = Value (lblIdTraining.Text)
            )
        ),
        {Status: "Didn't Present"}
    )))

 

 

King
Level: Powered On

Re: check if an email exists in a collection

Hello @EricLott ,

I'm sorry to bother you, the formula only updates me to the first filter element and that person attended


example

Person who did not appear:
ExampleEmail2@email.com


Person who appeared:
ExampleEmail1@email.com

 

The filter is updated to: ExampleEmail1@email.com

 

I think the problem is in the First (Filter ())
 
😞

EricLott
Level 10

Re: check if an email exists in a collection

Sorry, yeah the Patch() is throwing me off. Do you just need a collection of users that didn't present? That would just be my solution above, only after the ClearCollect() you can just use this:

Filter(PresentedResultSet,Presented=false)

 

Helpful resources

Announcements
New Ranks and Rank Icons in April

'New Ranks and Rank Icons in April

Read the announcement for more information!

Better Together’ Contest Finalists Announced!

'Better Together’ Contest Finalists Announced!

Congrats to the finalists of our ‘Better Together’-themed T-shirt design contest! Click for the top entries.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

thirdimage

Community Summit North America

Innovate, Collaborate, Grow - The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors
Users online (8,516)