web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to exclude outside...
Power Apps
Answered

How to exclude outside domain user when saving data in a Person column

(0) ShareShare
ReportReport
Posted on by 106

Hi, In my Power App I am taking my events from Outlook Calendar and saving data in a SharePoint list. In SharePoint list with other columns also I have a Person column (Allow : multiple) named "Participants" and another Single line text column named "OtherParticipants" where I need to save "requiredAttendees" field's value of Outlook event. 

Let's say the  value of requiredAttendees="mamun@mydomain.com;abc@mydomain.com;xyz@otherdomain.com;zyx@otherdomain.com;"

So now I have to save the value of "@mydomain.com" users to "Participants" column and "@otherdomain.com" users to "OtherParticipants" column. I have tried few ways to save data in the "Participants" column but for outside domain users I am getting error "An Unknown error occurred" message. below is my code (though I did not try to save data in the "OtherParticipants" column yet

Participants: If(requiredAttendees<>"",
 ForAll(
 Split(
 Left(requiredAttendees,Len(requiredAttendees)-1),
 ";"
 ),If(Text(Trim(Result)) in Office365Users.SearchUserV2().value.Mail,
 { 
 DisplayName: Office365Users.UserProfileV2(Text(Trim(Result))).displayName,
 Claims: "i:0#.f|membership|" & Lower(Office365Users.UserProfileV2(Text(Trim(Result))).userPrincipalName),
 Department: "",
 Email: Office365Users.UserProfileV2(Text(Trim(Result))).userPrincipalName,
 JobTitle: "",
 Picture: ""
 })
 )
 )

In the place of 2nd If condition (If(Text(Trim(Result)) in Office365Users.SearchUserV2().value.Mail), I have tried below ways also but always getting same error

1. IsMatch(Substitute(Right(Text(Trim(Result)),Len(Text(Trim(Result))) - Find("@",Text(Trim(Result)))),";",""),UserDomain,Contains & IgnoreCase)

2. Lower(Substitute(Right(Text(Trim(Result)),Len(Text(Trim(Result))) - Find("@",Text(Trim(Result)))),";",""))=Lower(UserDomain)

3. (Find(Lower(UserDomain),Lower(Text(Trim(Result)))))>0

4. !(IsEmpty(Office365Users.UserProfileV2(Text(Trim(Result)))))

5. If(Text(Trim(Result)) in Office365Users.SearchUserV2().value.Mail

 

Can you please help me actually what am I missing? Also if possible add code for "OtherParticipant" column

Very urgent help needed!!!

 

Thanks!

 

Categories:
I have the same question (0)
  • Verified answer
    KrishnaV Profile Picture
    5,023 on at

    Hi @hkmamun ,

     

    Try this:

    Participants: If(requiredAttendees<>"",
     ForAll(
     Split(
     Left(requiredAttendees,Len(requiredAttendees)-1),
     ";"
     ),If((Text(Trim(Result)) in Office365Users.SearchUserV2().value.Mail And !IsBlank(Office365Users.UserProfileV2(Text(Trim(Result))).displayName)),
     { 
     DisplayName: Office365Users.UserProfileV2(Text(Trim(Result))).displayName,
     Claims: "i:0#.f|membership|" & Lower(Office365Users.UserProfileV2(Text(Trim(Result))).userPrincipalName),
     Department: "",
     Email: Office365Users.UserProfileV2(Text(Trim(Result))).userPrincipalName,
     JobTitle: "",
     Picture: ""
     })
     )
     )


    I hope this resolved your issue if you see any challenge/need further help please let me know I am always happy to do it for my community.

    Regards,
    Krishna
    If this post helps you give a 👍 and if it solved your issue consider Accept it as the solution to help the other members find it more.

  • Verified answer
    v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @hkmamun ,

    Do you submit your data to your SP List using Patch function?

     

    Based on the formula that you mentioned, I think there is something wrong with it. I have made a test on my side, please take a try with the following workaround:

    Please consider modify your formula as below:

    Participants: If(
     requiredAttendees <> "",
     ForAll(
     Filter( // Add filter formula here to filter your domain users
     Split(
     Left(requiredAttendees, Len(requiredAttendees)-1),
     ";"
     ),
     Lower(Last(Split(First(Split(Office365Users.MyProfileV2().mail, ".")).Result, "@")).Result) in Lower(Result)
     ),
     { 
     DisplayName: Office365Users.UserProfileV2(Trim(Result)).displayName,
     Claims: "i:0#.f|membership|" & Lower(Trim(Result)),
     Email: Trim(Result),
     Department: "",
     JobTitle: "",
     Picture: ""
     }
     )
     )

    The following formula in above Filter function is used to get the domain name (e.g. mydomain) from your email address:

    Last(Split(First(Split(Office365Users.MyProfileV2().mail, ".")).Result, "@")).Result

    Please consider take a try with above solution, check if the issue is solved.

     

    For the "OtherParticipants" Text field inside your Patch function, please try the following formula:

    OtherParticipants: If(
     requiredAttendees <> "",
     Concat(
     Filter(
     Split(
     Left(requiredAttendees, Len(requiredAttendees)-1),
     ";"
     ),
     Not(Lower(Last(Split(First(Split(Office365Users.MyProfileV2().mail, ".")).Result, "@")).Result) in Lower(Result))
     ),
     Result & ";"
     )
    )

     

    Please consider take a try with above formula, then check if the issue is solved.

     

    Best regards,

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 427 Most Valuable Professional

#2
11manish Profile Picture

11manish 201 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard