Agentshevy Posted September 16, 2014 Posted September 16, 2014 I have a three layouts in my solution. Staff, student and Admin. And these three layouts correspond to Three privilege sets i have.. Now, I want to script the layouts such that each redirects a user (from a privilege set) to his/her appropriate layout once access has been denied.. I have already configured the security accounts and privilege sets, a student accout gets access denied message when entering a staff layout.. Etc.. But now, i want the layout to automatically redirect the user to his/her appropriate layout once it checks the privilege set.. Please how can I do that?
bcooney Posted September 17, 2014 Posted September 17, 2014 Well, I would rethink the three tables..they are all People. You might have also a Roles table (Student, Staff, Admin). Then, you would have a join table that stores all the combos: People->PeoRoles<-Roles As for navigation, use a File>Open script If (get (accountprivilegesetname) = "Staff" go to layout ("Staff") Else If (get (accountprivilegesetname) = "Admin" go to layout ("Admin") Else go to layout ("Student") End If However, you may consider one Main Menu layout and use Hide Object with Get (AccountPrivilegeSetName) to show/hide layout objects. Or..slide panels. So many tools at our disposable now! 1
Agentshevy Posted September 17, 2014 Author Posted September 17, 2014 thanks for your response..bcooney
Agentshevy Posted September 17, 2014 Author Posted September 17, 2014 However, you may consider one Main Menu layout and use Hide Object with Get (AccountPrivilegeSetName) to show/hide layout objects. Or..slide panels. Please how do I go about the above you stated? Am kinda new to filemaker.
Agentshevy Posted September 17, 2014 Author Posted September 17, 2014 As for navigation, use a File>Open script If (get (accountprivilegesetname) = "Staff" go to layout ("Staff") Else If (get (accountprivilegesetname) = "Admin" go to layout ("Admin") Else go to layout ("Student") End If I strongly understood the this one, but right now am confused as to where to actually place the script. Which layout am I goona place it?
bcooney Posted September 18, 2014 Posted September 18, 2014 The script will be set to run when the file opens as a script trigger. See File Options>Script Triggers>OnFirstWindowOpen
LaRetta Posted September 18, 2014 Posted September 18, 2014 One thing I would add here ... I cringe when I see hard-coding because it can break: go to layout ("Admin") There are resources which can show you how to use layout's internal IDs instead of the name. The problem with name is that if you change the name, you will break the reference. You may think now that you won't ever change them but time goes by and you (or a different developer who inherits your solution) might make the mistake. It is not worth the risk. Here are a few resources: http://filemakerstandards.org/display/cs/Layout+references http://fmforums.com/forum/topic/93456-defensive-coding-with-objects/ I use objectID (originally gleaned from Fabrice Nordmann) for EVERYTHING instead of hard-coding. Unfortunately, I do not know a way of protecting the privilege set names themselves; maybe there is. Anyway, protect the layout names for sure.
bcooney Posted September 18, 2014 Posted September 18, 2014 Go to Layout ("Admin") does not break if you change the layout name, LR. This isn't using layout by calc. Rather, selecting the layout from the layout chooser menu.
bruceR Posted September 18, 2014 Posted September 18, 2014 Note that the step LaRetta advises is only useful under certain circumstances; and those circumstances do not apply here. Â If you are using the one of the calculation methods (by name or by layout number) then the ID method can be useful. Â For standard layout navigation it is not necessary and FileMaker is already doing the work of handling the ID for you. Â You can safely rename your layouts or shuffle your layout order, and everything just works. Â Let's take an example: if you create a new layout and ALSO call that layout "Admin" FileMaker will continue going to the original layout. Â If you duplicate the Admin layout, rename the original as Admin - OLD, give the new layout the name Admin, your script will continue navigating to the original layout (the one now named as Admin - OLD)Â because the script was already using the internal ID.
LaRetta Posted September 18, 2014 Posted September 18, 2014 Oh okay. Well when you specify a layout, it lists as Go To Layout [ "Admin" (Admin) ] ... whereas, when you define layout by calculation it lists as: Go To Layout [ "Admin" ] ... so that is why I was thrown off. :-) Yes Bruce, it was the listing of the script step that made me think it was using layout by calculation, as I just explained. I KNOW FM keeps track of the internal ID when you select the layout. I STILL stand by using object IDs whenever you hard-code a name.
bcooney Posted September 19, 2014 Posted September 19, 2014 My apologies to all! I was lazy and wrote pseudo-code, and should have realized that what I wrote could have been taken literally. I almost never use layout by calculation -- because, as LaRetta points out, hard-coded layout references are not updated.
Agentshevy Posted September 20, 2014 Author Posted September 20, 2014 thanks to all your replies... Guess I have gotten it to work... Thanks
Agentshevy Posted September 20, 2014 Author Posted September 20, 2014 pleae, what is the meaning or function of the hash sign # in a script? Example, i do see some scripts like this # # set Variable # TriggerOff thats just an illustration not that the script is correct anyways.. What is the meaning of the # sign, function and how can I insert it?
LaRetta Posted September 20, 2014 Posted September 20, 2014 They are comments (see in your script list at the bottom of Miscellaneous section). Developers use it to separate script steps into groups and to add comments to the script about what is happening. :-)
Recommended Posts
This topic is 3718 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now