cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
diegomarino
Helper III
Helper III

restrict access to single record by user

Hi i read something to restrict access based on user

my question is a bit different from the stuff i found

 

may i restrict access for a single record to users except me (the admin)?

thanks

4 REPLIES 4
LRVinNC
Resident Rockstar
Resident Rockstar

Yes, you can as long as the record you want to return can be uniquely tied to that user.  Email address is the most reliable linkage to use because email address is always unique even though name may not be.  You can obtain the identity of the individual who is logged on to the application with User().Email.

 

I currently have an application that allows a user to submit and update their resume. When the user accesses the application, the only thing they will ever see is their own resume and associated information stored about themselves.  They cannot see anything else.  If an admin logs on they can see the records for any individual in the system.

LRVinNC

------------------
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

thanks for the answer

yes, i'd like to have some records visible only by me (admin)

i know the user().email...but how may i set a record visible only by me? 

The exact syntax is going to depend on the specifics of your application, but in mine, it's done with the filter on the gallery.  My app actually presents different information based on 3 different personnas:  an individual consultant, a manager or a resource manager.  I have a series of checks that set global variables that tell me if the person is a manager or resource manager, then I have an If statement that looks at those global variables and performs the right filter.  A very simplified version of my code would be something like this. 

//* check to see if the person has been identified as a resource manager
If (IsResourceManager, 
         Filter(ListOfData, <list of conditions>, 
//* if they weren't a resource manager, check to see if they are a manager
    IsManager, 
         Filter(colResources, Email4Resource in AllReports.userPrincipalName || 
                 Email4Resource in AllReports.UserPrincipalName,
//* if they weren't a resource manager or a manager, they must be an individual
    Filter(colResources,Email4Resource = CurrentUserEmail))

My data is loaded into a collection (colResources) and I have a second collection I have built which lists the identities of the manager's direct reports (AllReports).

LRVinNC

------------------
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

thanks very much

i decided to add a yes/no field called manager, if is true my collaborator cannot see the record

If(
    User().FullName = "diego marino";
    Filter(
        Candidati;
        StartsWith(
            ComuneDesc;
            TBcandidatifiltrocomune.Text
        ) && (IsBlank(TBcandidatifiltroptftrasferibile.Text) || DPcandidatifiltroptftrasferibile.Selected.Value = "=" && 'Ptf trasferibile personale' = Value(TBcandidatifiltroptftrasferibile.Text) || DPcandidatifiltroptftrasferibile.Selected.Value = ">=" && 'Ptf trasferibile personale' >= Value(TBcandidatifiltroptftrasferibile.Text) || DPcandidatifiltroptftrasferibile.Selected.Value = "<=" && 'Ptf trasferibile personale' <= Value(TBcandidatifiltroptftrasferibile.Text)) && (StartsWith(
            Cognome;
            TBcercacandidato.Text
        )) && (IsBlank(TBcandidatifiltroptfbanca.Text) || DPcandidatifiltroptfbanca.Selected.Value = "=" && 'Ptf banca personale' = Value(TBcandidatifiltroptfbanca.Text) || DPcandidatifiltroptfbanca.Selected.Value = ">=" && 'Ptf banca personale' >= Value(TBcandidatifiltroptfbanca.Text) || DPcandidatifiltroptfbanca.Selected.Value = "<=" && 'Ptf banca personale' <= Value(TBcandidatifiltroptfbanca.Text))
    );
    Filter(
        Candidati;
        StartsWith(
            ComuneDesc;
            TBcandidatifiltrocomune.Text
        ) && (Manager <> true) && (IsBlank(TBcandidatifiltroptftrasferibile.Text) || DPcandidatifiltroptftrasferibile.Selected.Value = "=" && 'Ptf trasferibile personale' = Value(TBcandidatifiltroptftrasferibile.Text) || DPcandidatifiltroptftrasferibile.Selected.Value = ">=" && 'Ptf trasferibile personale' >= Value(TBcandidatifiltroptftrasferibile.Text) || DPcandidatifiltroptftrasferibile.Selected.Value = "<=" && 'Ptf trasferibile personale' <= Value(TBcandidatifiltroptftrasferibile.Text)) && (StartsWith(
            Cognome;
            TBcercacandidato.Text
        )) && (IsBlank(TBcandidatifiltroptfbanca.Text) || DPcandidatifiltroptfbanca.Selected.Value = "=" && 'Ptf banca personale' = Value(TBcandidatifiltroptfbanca.Text) || DPcandidatifiltroptfbanca.Selected.Value = ">=" && 'Ptf banca personale' >= Value(TBcandidatifiltroptfbanca.Text) || DPcandidatifiltroptfbanca.Selected.Value = "<=" && 'Ptf banca personale' <= Value(TBcandidatifiltroptfbanca.Text))
    )
)

i tried to add a single condition between the other to save code but didn't work

 

Filter(
    Candidati;
    StartsWith(
        ComuneDesc;
        TBcandidatifiltrocomune.Text
    ) && (User().FullName = "Diego marino" || Manager <> true) && (IsBlank(TBcandidatifiltroptftrasferibile.Text) || DPcandidatifiltroptftrasferibile.Selected.Value = "=" && 'Ptf trasferibile personale' = Value(TBcandidatifiltroptftrasferibile.Text) || DPcandidatifiltroptftrasferibile.Selected.Value = ">=" && 'Ptf trasferibile personale' >= Value(TBcandidatifiltroptftrasferibile.Text) || DPcandidatifiltroptftrasferibile.Selected.Value = "<=" && 'Ptf trasferibile personale' <= Value(TBcandidatifiltroptftrasferibile.Text)) && (StartsWith(
        Cognome;
        TBcercacandidato.Text
    )) && (IsBlank(TBcandidatifiltroptfbanca.Text) || DPcandidatifiltroptfbanca.Selected.Value = "=" && 'Ptf banca personale' = Value(TBcandidatifiltroptfbanca.Text) || DPcandidatifiltroptfbanca.Selected.Value = ">=" && 'Ptf banca personale' >= Value(TBcandidatifiltroptfbanca.Text) || DPcandidatifiltroptfbanca.Selected.Value = "<=" && 'Ptf banca personale' <= Value(TBcandidatifiltroptfbanca.Text))
)

 

 

 

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Top Kudoed Authors
Users online (2,983)