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

Verify all substrings are email addresses, if not, add @domainname.com to substring

I have a multi-line text field that may contain multiple email addresses (required becaues SharePoint doesn't do DGs in People Picker).

 

I'd like to split the text up by the ; delimiter between each entry and then check that each contains the FQDN and not just an alias ("alias@microsoft.com" not just "alias").

 

In Javascript, I can use split() to evaluate each grouping by ; (semi-colon) , how do I do this in PowerApps? IsMatch(ThisItem.ItemName,Email) will do an evalutation of the full field/string, but how do I split it apart into substrings?

 

I will then take that substring and if true, pass the value along, if false, add the FQDN to the alias and then pass it along.  

 

Tips on any part or full formala would be appreciated.

3 REPLIES 3
Highlighted
Power Apps
Power Apps

Re: Verify all substrings are email addresses, if not, add @domainname.com to substring

Currently there's no way to split a string into multiple values (you can use the functions Find/Left/Right to split one string into two, but not into an arbitrary number of substrings). There's a feature request to add this functionality in the PowerApps Ideas page, please vote it up to get it on the radar of the product team.

Highlighted
Power Apps
Power Apps

Re: Verify all substrings are email addresses, if not, add @domainname.com to substring

The latest PowerApps release now has a Split function, which can do this. For example, this expression will tell whether a text input contains only e-mails separated by semicolons.

Concat(Split(TextInput2.Text, ";"), If(IsMatch(Result, Match.Email), "","E")) = ""

While this expression below will add the missing '@domain.com' if the part doesn't have a '@':

Concat(
    Split(TextInput2.Text, ";"),
    If(
        IsBlank(Find("@", Result)),
        Result & "@domain.com",
        Result),
    ";")

 

Highlighted
Advocate I
Advocate I

Re: Verify all substrings are email addresses, if not, add @domainname.com to substring

Thanks for the contribution from you guys.

Actually, when implementing the partial solution to verify a textbox with 1 or more valid emails, separeted by semicolons, I faced an issue that 1 email could be validated taking more then one @... also, if I put a semicolon at the end of the first email, the formula show an error, that actually is not an error.
So, to correct this issues, I adjusted the formula to the follow:

 

Spoiler
Concat(Split(TextInput1.Text, ";"), If(CountRows( MatchAll(Result, "@"))=1 &&
                                                      (IsBlank(Result) || IsMatch(Result, Match.Email)), "" , "Error")) = ""

The first pice of formula will garantee that only one @ must be inserted in the same email.

Spoiler
CountRows( MatchAll(Result, "@"))=1 &&

The second pice, will verify if the emails match, even if is blank (in the case of just insert a ; at the end of an email).

Spoiler
(IsBlank(Result) || IsMatch(Result, Match.Email))

Hope this help.

Thanks again.

 

 

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (9,052)