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 / Calling Office 365 Use...
Power Apps
Answered

Calling Office 365 Users connection multiple times in an If-statement

(0) ShareShare
ReportReport
Posted on by 19

Hi!

I am making an app to get an overview of the users who have booked the meeting rooms in my department.

 

Because there are so many ways to book rooms in Outlook, the syntax has to account for solutions where the user who book can end up being both the organizer for the event, but also just a required attendee. 

Likewise, the meeting room might sometimes be an organizer, and at other times a resource attendee, an optional attendee, or a required attendee.

 

I have made an if-statement with two different alls to the Office 365 Users-connection, based on whether the user is the organizer or an attendee. However, the If-statement runs both calls, and since only one of them will ever be true at any time, I get a 404 error. 

Any ideas on how to make it so that the code skips the call that doesn't match the inital check? Or, any other tips on how to make this work? I feel like the solution is probably simple, but I am just so lost on this one 😅

 

 

 

 

If(
 //Checks if there is a reservation on the meeting room. If yes, returns photo, if no, returns icon showing free
 IsEmpty(Search(colEvents,"MeetingRoom","organizer","optionalAttendees","requiredAttendees","resourceAttendees")),
 
 //If the meeting room is not organizer, looks up user as organizer
 If(
 IsBlank(LookUp(colEvents,"MeetingRoom" in organizer)),
 'Office365-brukere'.UserPhotoV2(
 LookUp(colEvents,"MeetingRoom" in resourceAttendees Or organizer Or optionalAttendees,organizer)),
 
 //If meeting room is organizer, looks up user from Required Attendees, and cleans string
 'Office365-brukere'.UserPhotoV2(
 Left(LookUp(colEvents,"MeetingRoom" in organizer,requiredAttendees),
 Len(LookUp(colEvents,"MeetingRoom" in organizer,requiredAttendees))-1))),
 
 //If no, show space as free
 ledig_ico)

 

 

 

 

Any tips would be very welcome!

Categories:
I have the same question (0)
  • Verified answer
    idanorin Profile Picture
    19 on at

    Ended up solving this by putting the If-statement within the Outlook 365-call. 

     

    Additionally, I am running the if-statement first with an IsBlankOrError to ensure that the statement will return an id for the office365-connection to use. If it does, I pass on the query. If not, it instead puts in a placeholder icon. 

     

    //Same code snippet twice – first to check for error or blank – if it is, it will show reservation icon
     If(!IsBlankOrError('Office365-brukere'.UserPhotoV2(
    
     If(
     
     //If meeting room is organizer, fetch participant from requiredAttendees, and clean string to fetch image
     !IsBlank(LookUp(colEvents,"MeetingRoom" in organizer)),
     (Left(LookUp(colEvents,"MeetingRoom" in organizer,requiredAttendees),
     Len(LookUp(colEvents,"MeetingRoom" in organizer,requiredAttendees))-1)),
    
    
     //If participant is organizer, fetch image
     !IsBlank(Search(colEvents,"MeetingRoom","optionalAttendees","requiredAttendees","resourceAttendees")),
     First(Search(colEvents, "MeetingRoom", "optionalAttendees", "requiredAttendees", "resourceAttendees")).organizer))), 
    
    'Office365-brukere'.UserPhotoV2(
    
     If(
     
     //If meeting room is organizer, fetch participant from requiredAttendees, and clean string to fetch image
     !IsBlank(LookUp(colEvents,"MeetingRoom" in organizer)),
     (Left(LookUp(colEvents,"MeetingRoom" in organizer,requiredAttendees),
     Len(LookUp(colEvents,"MeetingRoom" in organizer,requiredAttendees))-1)),
    
     //If participant is organizer, fetch image
     !IsBlank(
    Search(colEvents,"MeetingRoom","optionalAttendees","requiredAttendees","resourceAttendees")),
     First(Search(colEvents, "MeetingRoom", "optionalAttendees", "requiredAttendees", "resourceAttendees")).organizer)),
    
     
     //If room is free, set reservation icon
    
    ledig_ico)

     

  • v-qiaqi@microsoft.com Profile Picture
    on at

    Hi @idanorin,

    Thanks for your sharing.

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 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard