September 16, 201411 yr 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?
September 17, 201411 yr 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!
September 17, 201411 yr Author 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.
September 17, 201411 yr Author 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?
September 18, 201411 yr The script will be set to run when the file opens as a script trigger. See File Options>Script Triggers>OnFirstWindowOpen
September 18, 201411 yr 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.
September 18, 201411 yr 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.
September 18, 201411 yr 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.
September 18, 201411 yr 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.
September 19, 201411 yr 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.
September 20, 201411 yr Author thanks to all your replies... Guess I have gotten it to work... Thanks
September 20, 201411 yr Author 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?
September 20, 201411 yr 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. :-)
Create an account or sign in to comment