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
Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on August 17, 2022 at 8am PDT.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Users online (4,187)