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

If function in Forall

I want to set the mail address using a person's name from the data source.

However, there are some irregular data in data source("","NA"), on top of the user name.

So in such a case, I just want to skip and just want to search the actual user name.

However, when I use "If" function in Forall, I supposed that Forall just skip false case of if condition, but it seems to return something(maybe false or blank), so my below formula doesn't work well.

How to configure just skip the case of false in If function in ForAll?

Thank you for your support.

 

ForAll(Recipients, If(Not(psn in ["","NA"]),{
'@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
DisplayName:First(Office365Users.SearchUser({searchTerm:psn}).DisplayName).DisplayName,
Claims:"i:0#.f|membership|" & Lower(First(Office365Users.SearchUser({searchTerm:psn}).Mail).Mail),
Department:"",
Email:First(Office365Users.SearchUser({searchTerm:psn}).Mail).Mail,
JobTitle:"",
Picture:""
}))

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: If function in Forall

@Kenjoy84 

My apology...I didn't notice that I had the formula a little off.

Should be this:

ForAll(Filter(Recipients, !IsBlank(psn) || psn = "NA"),
   With({usr: First(Office365Users.SearchUser({searchTerm:psn}))},
       {
           '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
           DisplayName:usr.DisplayName,
           Claims:"i:0#.f|membership|" & Lower(usr.Mail),
           Department:"",
           Email:usr.Mail,
           JobTitle:"",
           Picture:""
       )
    )
)

 

This will return a table of records with the user information filtered by the criteria you need.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

4 REPLIES 4
Highlighted
Super User III
Super User III

Re: If function in Forall

@Kenjoy84 

Consider filtering out the things you don't want in your ForAll and then only operating on the ones you do.  

This formula should give you what you need:

ForAll(Filter(Recipients, !IsBlank(psn) || psn = "NA"),
   {
       '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
       With({usr: First(Office365Users.SearchUser({searchTerm:psn}))},
           DisplayName:usr.DisplayName,
           Claims:"i:0#.f|membership|" & Lower(usr.Mail),
           Department:"",
           Email:usr.Mail,
           JobTitle:"",
           Picture:""
       )
   }

)

Also, consolidated the SearchUser to one time for this rather than multiple calls to the function.

 

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Highlighted
Helper II
Helper II

Re: If function in Forall

@RandyHayes Thank you!

The filter part works perfectly! 

However, additional your point about using "With" to consolidate function, it seems error and I can't solve, eventually.

Could you find out the solution for this? Thank you very much.

 

pic.jpg

Highlighted
Super User III
Super User III

Re: If function in Forall

@Kenjoy84 

My apology...I didn't notice that I had the formula a little off.

Should be this:

ForAll(Filter(Recipients, !IsBlank(psn) || psn = "NA"),
   With({usr: First(Office365Users.SearchUser({searchTerm:psn}))},
       {
           '@odata.type': "#Microsoft.Azure.Connectors.SharePoint.SPListExpandedUser",
           DisplayName:usr.DisplayName,
           Claims:"i:0#.f|membership|" & Lower(usr.Mail),
           Department:"",
           Email:usr.Mail,
           JobTitle:"",
           Picture:""
       )
    )
)

 

This will return a table of records with the user information filtered by the criteria you need.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

Highlighted
Helper II
Helper II

Re: If function in Forall

@RandyHayes Thank you, Randy! This works as I expected. I appreciate your clarification.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

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

Top Solution Authors
Top Kudoed Authors
Users online (7,441)