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

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Access to PowerApps da...
Power Apps
Unanswered

Access to PowerApps data for guest users

(0) ShareShare
ReportReport
Posted on by 36

Hello,

I would like to solve the following:

I have students, who have O365 accounts. Their parents have guest accounts. Students and both parents should have read access to an app which shows the grades of the student.

So far it is possible that the student and one of the parents (Eltern1) have access to the data in the app but not the second parent (Eltern2).

Here is my code:

If(User().Email in 'Office365-Gruppen'.ListGroupMembers("8817934c-f6aa-43c5-a893-4e62ac6c5384").value.mail
;
Set(varVorname;LookUp(Klassenzugehoerigkeit;Eltern1=User().FullName;Vorname));;
Set(varNachname;LookUp(Klassenzugehoerigkeit;Eltern1=User().FullName;Nachname))
;
Set(varVorname;LookUp(Klassenzugehoerigkeit;Eltern2=User().FullName;Vorname));;
Set(varNachname;LookUp(Klassenzugehoerigkeit;Eltern2=User().FullName;Nachname))
;
Set(varNachname;'Office365-Benutzer'.MyProfile().Surname);;
Set(varVorname;'Office365-Benutzer'.MyProfile().GivenName))
;;

What is wrong in the code? How can I provide access to the student's data for the second parent (Eltern2) too?

Thanks and best regards,

hpc

Categories:
I have the same question (0)
  • rpersad Profile Picture
    776 on at
    Re: Access to PowerApps data for guest users

    First there are syntax errors with your code. You are using semi-colons, ";", instead of commas ",".

    Also use the code below to get the First Name of the user that is currently logged into the app:

     

    First(Split(User().FullName, " ")).Value

     

    To get the surname of the user that is currently logged into the app use the code below:

     

    Last(Split(User().FullName, " ")).Value,

     

     

    Question:

    1. What the the purpose of the if statement?
    2. What is the value stored in the column Eltern1 and Eltern2?

     

    Here is the syntax fixed for your If statement

     

    If(User().Email in 'Office365-Gruppen'.ListGroupMembers("8817934c-f6aa-43c5-a893-4e62ac6c5384").value.mail
    ,
    Set(varVorname,LookUp(Klassenzugehoerigkeit,Eltern1 = First(Split(User().FullName, " ")).Value));
    Set(varNachname,LookUp(Klassenzugehoerigkeit,Eltern1 = Last(Split(User().FullName, " ")).Value)
    ,
    Set(varVorname,LookUp(Klassenzugehoerigkeit,Eltern2=Office365Users.MyProfileV2().givenName));
    Set(varNachname,LookUp(Klassenzugehoerigkeit,Eltern2=Office365Users.MyProfileV2().surname))
    )

     

     

  • hpc Profile Picture
    36 on at
    Re: Access to PowerApps data for guest users

    Hi rpersad,

    thanks for help.

    The german version of PowerApps uses ";" for "," and ";;" for ";".

    The if-statement checks, if the guest is member of the group.

    Eltern1 contains the name of one parent, Eltern2 the name of the second parent.

    So far I couldn't get your code to work: varVorname and varNachname wouldn't load.

  • hpc Profile Picture
    36 on at
    Re: Access to PowerApps data for guest users

    I made a step forward, but the code is still not working properly:

     

    Switch(User().Email in 'Office365-Gruppen'.ListGroupMembers("8817934c-f6aa-43c5-a893-4e62ac6c5384").value.mail
    ;
    Set(varVorname;LookUp(Klassenzugehoerigkeit;Eltern1=User().FullName;Vorname));
    Set(varNachname;LookUp(Klassenzugehoerigkeit;Eltern1=User().FullName;Nachname))
    ;;
    Set(varVorname;LookUp(Klassenzugehoerigkeit;Eltern2=User().FullName;Vorname));
    Set(varNachname;LookUp(Klassenzugehoerigkeit;Eltern2=User().FullName;Nachname))
    ;
    Set(varNachname;'Office365-Benutzer'.MyProfile().Surname);;
    Set(varVorname;'Office365-Benutzer'.MyProfile().GivenName))

     

    Now when user "Eltern1" starts the app he sees the surname of the Office365 User but not the given name. The variable varVorname is empty.

    When user "Eltern2" starts the app he sees the given name of the Office365 User but not the surname. The variable varNachname is empty.

    Do I set the ; and the ;; wrong?

  • rpersad Profile Picture
    776 on at
    Re: Access to PowerApps data for guest users

    Firstly the syntax for you switch statement is incorrect. Here is the documentation.

     

    What data type does the columns, Eltern1 and Eltern2 return?

  • hpc Profile Picture
    36 on at
    Re: Access to PowerApps data for guest users

    Thank you. Data type for Eltern1 and Eltern2 is text. The columns contain given name and surname, e.g. Eltern1 Joe Doe, Eltern2 Mary Doe.

  • rpersad Profile Picture
    776 on at
    Re: Access to PowerApps data for guest users

    This should be the correct syntax for the switch condition. The Switch statement determines if the condition, in your case 

    User().Email in 'Office365-Gruppen'.ListGroupMembers("8817934c-f6aa-43c5-a893-4e62ac6c5384").value.mail

    to see if it is true then will process the first two set functions,

    Set(varVorname;LookUp(Klassenzugehoerigkeit;Eltern1=User().FullName;First(Split(Eltern1, " ")).Value));;
    Set(varNachname;LookUp(Klassenzugehoerigkeit;Eltern1=User().FullName;Last(Split(Eltern1, " ")).Value))

    and exit the switch statement. If the condition was false it would process the other set functions,

    Set(varVorname;LookUp(Klassenzugehoerigkeit;Eltern2=User().FullName;First(Split(Eltern2, " ")).Value));;
    Set(varNachname;LookUp(Klassenzugehoerigkeit;Eltern2=User().FullName;Last(Split(Eltern2, " ")).Value))
    );;

     

    Here is the full Switch statement code

    Switch(true
    ;
    User().Email in 'Office365-Gruppen'.ListGroupMembers("8817934c-f6aa-43c5-a893-4e62ac6c5384").value.mail;
    Set(varVorname;LookUp(Klassenzugehoerigkeit;Eltern1=User().FullName;First(Split(Eltern1, " ")).Value));;
    Set(varNachname;LookUp(Klassenzugehoerigkeit;Eltern1=User().FullName;Last(Split(Eltern1, " ")).Value))
    ;
    Set(varVorname;LookUp(Klassenzugehoerigkeit;Eltern2=User().FullName;First(Split(Eltern2, " ")).Value));;
    Set(varNachname;LookUp(Klassenzugehoerigkeit;Eltern2=User().FullName;Last(Split(Eltern2, " ")).Value))
    );;

     

    However for the code below would process given there is no condition to be met and would rewrite the data stored in the variables varNachname and varVorname which you have used in your Set statements above. Is there another condition you want to run this code for?

    Set(varNachname;'Office365-Benutzer'.MyProfile().Surname);;
    Set(varVorname;'Office365-Benutzer'.MyProfile().GivenName))

     

  • HansPeter Profile Picture
    3 on at
    Re: Access to PowerApps data for guest users

    I don't get your code to work.

     

    Mine works, but only for Eltern1.

  • rpersad Profile Picture
    776 on at
    Re: Access to PowerApps data for guest users

    Are you getting any error messages?

  • hpc Profile Picture
    36 on at
    Re: Access to PowerApps data for guest users

    No, no error messages. I give up. I leave it as it is with only 1 parent who has access to the app.

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 322 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 209 Super User 2025 Season 2

Last 30 days Overall leaderboard