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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Error Handling in FORA...
Power Apps
Unanswered

Error Handling in FORALL and Collections for adding users to Office365Groups

(0) ShareShare
ReportReport
Posted on by 2

In Power Apps  - App is adding selected users (which exist in Azure) to a Office365group.

 

For All(
my collection,
Office365Groups.AddMemberToGroup(
"xxx",
Id
)
);

 

How would you add an error handling routine where if all the items from the collection was added then  "User(s) Added Successfully" Notification is displayed otherwise "Only User(s) that do not exist in Group were Added" Notification is displayed

Categories:
I have the same question (0)
  • Rajkumar_M Profile Picture
    3,741 Super User 2025 Season 2 on at

    Hi

     

    To add error handling to your code in Power Apps, you can utilize a combination of functions like 'If', 'ForAll', and 'Notify'.

     

    ClearCollect(
    UserAddResults,
    ForAll(
    myCollection,
    {
    Result: Office365Groups.AddMemberToGroup("xxx", Id)
    }
    )
    );
    // Check if any user failed to be added to the group
    If(
    CountRows(Filter(UserAddResults, Result <> 200)) = 0,
    Notify("User(s) Added Successfully", Success),
    Notify("Only User(s) that do not exist in Group were Added", Error)
    );

     

    (Or)

     

    ForAll( 
    MyCollection,
    If(
    Office365Groups.AddMemberToGroup("xxx", Id),
    Notify("User(s) Added Successfully", NotificationType.Success),
    Notify("Only User(s) that do not exist in Group were Added", NotificationType.Error) ) )

     

    Thanks!

     

    If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation. 

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard