Roles/Home Pages

  • 0
  • 1
  • Question
  • Updated 9 months ago
  • In Progress
Hello everyone!

I finished building my first app and I am now starting to build roles/home pages.  We have a need for 100 roles and 100 home pages.  I'm thinking there must be a simpler way to do this.  It would be a nightmare trying to maintain 100 home pages and 500 reports (each home page will have five reports).  Is there a way to only create one role and one home page where the role will display only records based on a user's location and the home page will only display the reports based on the user's location too?

Thank you in advance!
Photo of Javier Martinez

Javier Martinez

  • 356 Points 250 badge 2x thumb

Posted 9 months ago

  • 0
  • 1
What do you mean by user's location? Did you mean the user's role?
Photo of Javier Martinez

Javier Martinez

  • 356 Points 250 badge 2x thumb
No, we have 100 different locations.  Records can be created by users in these locations.
Photo of Evan Martinez

Evan Martinez, Community Manager

  • 12,348 Points 10k badge 2x thumb
Hi Javier, 

Congratulations on building your first app! For the 100 roles/home pages, do you need them because you have over a 100 locations? Would there be a logic to how a user is assigned to a record? Perhaps a field where a user is assigned to a record that would show what records were relevant to that which user? 
The right way to do this is to have a table of users and their location.  The Key field to that user should be the Userid field.

Then on any table where you need to control access you create a formula user field called [Current User] with a formula of

User()

That function will calculate to the current user.  Then lookup the location down to the details table.

Then set up Role Permission with a Custom Rule for these users which are restricted by userid location.  Maybe that would be a good name for the Role. "Restricted by userid location"

The Custom Rule would be where [location lookup] = location.

Then you just need 1 Role for those 100 users and 1 Dashboard and one set of those 5 reports.




Photo of Javier Martinez

Javier Martinez

  • 356 Points 250 badge 2x thumb
Thank you very much!  I created the formula user field and it's pulling the user's name.  Can you clarify one thing for me please? 

"That function will calculate to the current user.  Then lookup the location down to the details table."

How do I do this part?  My apologies, still kind of new to this.
np, I did leave out a step.

After reconfirming that you haver set the Key field of the Users table to be the userid field, you will make a Relationship between the the Users table  and the details table.  Do not let the system make the field called [Related User] when you are building that relationship, but instead select the field you created called [Current user].

Feel free to post back if you have any problems.
Photo of Javier Martinez

Javier Martinez

  • 356 Points 250 badge 2x thumb
I don't see the userid field in the Users Table.  I currently have Employee Number as the Key Field

You will need to create a new field called Userid of type User and manually populate it.

Did you already have that table setup and is it already being used in any relationships?
Photo of Javier Martinez

Javier Martinez

  • 356 Points 250 badge 2x thumb
Yes, I already had it set up and I am using it in another relationship to the same table where i created the Current User formula field.
To make this technique work, you will need to have the Key field be the userid.  Can you tell me if for that existing relationship, is the data entry manual?  ie are you manually assigning each of your detail records to a user?
Photo of Javier Martinez

Javier Martinez

  • 356 Points 250 badge 2x thumb
The relationship is a lookup field Where the user technically selects themselves as the person creating the record.  I am thinking that can automatically be done to capture the person creating the record too instead of the user selecting themselves from a drop down list of 20k+ people.  Currently, they can search for their employee number.
I suppose that if this is a required field and you are happy with that data entry method of the user selecting themself, then the location lookup can come from that existing relationship.
Photo of Javier Martinez

Javier Martinez

  • 356 Points 250 badge 2x thumb
If I User Employee Number, do I need to change the formula field I created and use something else instead of user()?
Photo of Javier Martinez

Javier Martinez

  • 356 Points 250 badge 2x thumb
If I User Employee Number, do I need to change the formula field I created and use something else instead of user()?
Photo of Javier Martinez

Javier Martinez

  • 356 Points 250 badge 2x thumb
Also, I don't see the Current User field I created when building the relationship to select it instead of Related User...
Photo of Javier Martinez

Javier Martinez

  • 356 Points 250 badge 2x thumb
Also, I don't see the Current User field I created when building the relationship to select it instead of Related User...
You would need to change the Key field of the Users table to be the Userid field to have that field being offered up as a choice.

If the drop down list is 20,000 employees, then I'm not understanding your app well enough to be sure of my advice.  I doubt that you have 20,000 users.

Perhaps you need to have a new separate table of these 100 users who are restricted by Role and have the Key field of that table be a userid field type.
(Edited)
Photo of Javier Martinez

Javier Martinez

  • 356 Points 250 badge 2x thumb
I'm stuck on this.  If I create a new Userid Field, it will be blank and it doesn't let me set it as a Key Field.  Not all 20k will use the app, but there are more than 100 users.  I'm lost, lol.
Photo of Javier Martinez

Javier Martinez

  • 356 Points 250 badge 2x thumb
I'm stuck on this.  If I create a new Userid Field, it will be blank and it doesn't let me set it as a Key Field.  Not all 20k will use the app, but there are more than 100 users.  I'm lost, lol.
I suggest setting up a new table used to control access.  Make fields there for the userid and the location.
Set the Key field there to be the userid field and then follow my original instructions to maker a relationship to the details table based on the field [Current User]

You will need to enter those 100 users into that table.
(Edited)
Photo of Javier Martinez

Javier Martinez

  • 356 Points 250 badge 2x thumb
Thanks Mark, but I will definitely have more than 100 users.  Not sure if this solution can support 500+ users.  I created the Userid Field and did the steps above and it still wasn't working for me.
The solution can support 500 users.
Can you tell me what is not working?

Are you getting the lookup of the location for the current user populated down to the detail records.
Photo of Javier Martinez

Javier Martinez

  • 356 Points 250 badge 2x thumb

Let me explain how the app works.  The app will have about 500 users.  The users are in different locations throughout the country and will create records called arbitrations.  The arbitrations will be reviewed by a team and either approved or denied.  If they are approved, a section in the table will be adjusted and now another Station will be charged and they will need visibility to those records to see why the arbitration was adjusted.

I am trying not to create 100 home pages (100 locations) and 100 roles (1 role for each location and each location will have multiple users).  Each home page has the same 5 reports.

I created the new filed Current User and have User() in the formula.  This works great.  I can't get the second part that you said to work.  The second table with the users has the Employee Number as the key field.  I can create a new table like you said for user access and create just two fields: Userid (User) and Location (Text).  The Userid field is blank if I do an upload so I can't set it as a key field.  How can I get the Userid to populate or will I have to select them all manually?

I apologize, but this is new to me.  I am trying to save some work and a nightmare in maintaining so many roles/home pages/reports.

To control access based on the user, yes you will need to have a new table for the users and a field for the location.  I believe that you can upload the email address into the user field.

You may want to consider if some users need access to multiple locations.  If that is the case you may want to have a multi select field and then control access using a "Contains"  formula field

IF(Contains(ToText([Locations lookup field from Users], [Location]), true)
Photo of Javier Martinez

Javier Martinez

  • 356 Points 250 badge 2x thumb
Ok, I created the Users table and was able to create the relationship.  I followed your instructions above and selected the Location from the Users table.  Now I have two fields (one labeled Current User that pulls up the current user and one that was created with the relationship called Current User - Location).  However, they are both pulling the current user...
(Edited)
On the relationship between users and  the detail records, there should be a field looking up the Location field.  Maybe try recreating that lookup field.
(Edited)