Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 3718 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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?

Posted

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!

  • Like 1
Posted

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.

Posted

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?

Posted

The script will be set to run when the file opens as a script trigger. See File Options>Script Triggers>OnFirstWindowOpen

Posted

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.  

Posted

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.

Posted

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.

post-62898-0-01022700-1411070161_thumb.p

Posted

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.

Posted

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.

Posted

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?

Posted

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.  :-)

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.