2 Replies Latest reply on Dec 22, 2010 11:26 AM by yuichim

    Showing different layout depending on user's department?



      Showing different layout depending on user's department?



      Basically I am writing a startup script and have layout redirect depending on the user's department.

      Ex: User has a department record called "Sales" and when he logs in, the startup script automatically finds out which department he or she is and redirects to the correct dashboard layout. 
      I thought of making a if-else statement by finding out the user department by matching the get(accountname) (since the accountname and "user full name" is the same) and the department name.

      I know a bit of mysql and would like to do this:    Select "x" from "table" where id="1"?

      What would be the best way to do this? Or there are other solutions?

      Any help much appreciated..

        • 1. Re: Showing different layout depending on user's department?

          Somehow you'll need to identify the person's department from their log in. Account Name and PrivilegeSet name are two things you can check with a get function and either might work here.

          You can perform a find to get the person's department ( and determine the appropriate layout ) or you can use a relationship.

          Let's say you have Two Tables: Departments and Users.

          Departments would have these fields:

          DepartmentID  (auto-entered serial number)
          Department Name
          Layout Name (or you can use layout number)

          Users would have these fields:

          Define a global text field, gAccountName in a third table, Start (this can actually be any table, even one of the two listed above)

          Define these relationships:
          Start::gAccountName = Users::AccountName

          Users::DepartmentID = Departments::DepartmentID

          Now your start up script:

          Go To layout [Start]
          Set Field [Start::gAccountName ; Get ( AccountName ) ]
          Go To layout [Departments::Layout Name ] // Use Layout Name by Calculation option

          • 2. Re: Showing different layout depending on user's department?

            Hi PhilModJunk,

            Thanks for your help! As Always!

            After posting the forum, I thought about it a while and came up with a solution... (I think).
            It actually is very similar to your solution or actually the same.

            So here is what I did.

            Under Fileoptions, I have it to perform a script called "Startup Script" in which it performs the following.

            1) Set a global field called accountname with get(AccountName)
            2) Go to layout called "layout selector"

            3) In Layout: layout selector (Users Table) , I inserted 3 fields with User's full name (which is the same as the accountName), globalfield "accountname" from step 1, and department name(which user is associated).
            4) I then created a layer script trigger "OnLayoutEnter" to trigger a script:

             a. Find the User's record by the AccountName
             b. Then get the department
             c. Trigger Go To Layout by the department by If else statement.

            So far when I tested it, it is working Smile

            I appreciate for the help and the input!!
            Thank you!