This is a public Forum  publicRSS

Forum post

    David583
    Pattern countAnswered
    Forum post posted February 24, 2011 by David583 , last edited February 9, 2012
    857 Views, 5 Comments
    Title:
    Pattern count
    Post:

    Filemaker Pro10 & 11 (built on 10), Filemaker 11 Server, shared network, windows XP & vista

     

    I am trying to get a count of 'Administrator' in my privilege field on my User Table.

    The user table is accessed by portal, which is on a layout based on a different table.

    the privilege field is set to hold 'Administrator', 'User' and 'Guest' only by drop down list. I only want one administrator.

    In my 'create new user' script I want to test this field, if the result is > or = to 1, It stops the user being created.

    On my user table I have created a calculated field : 'PatternCount ( privilege_set ; "Administrator" )'

    My problem is it doesn't seem to work. I'm not sure if it is the syntax of the calculation or the fact that it is on a layout the table is not on.

    Any help would be appreciated :)

    Best Answer

    David583

    Got It!!!!!!!!!!!!

    It was something simple I overlooked after all

    I needed a summary of your calculation, now I can test the summary and it works fine.

    Thanks again for your help

    David:)

    Answer

     

    • Sorbsbuster

      I think that you need to pick up the field privilege_set by the correct relationship, and by the List function, so:

      PatternCount ( List ( RealationshipToThatTable::privilege_set ; "Administrator" )

    • David583

      Thanks Sorbsbuster,

      I gave that a try but still no result as before, the calc I tried is

      PatternCount ( List( USERS::privilege_set ) ; "Administrator" ).

      The relationship I have is a cartesian (x) as Admin table has only one record but there can be many users. (The Admin table holds most globals and common calculations and the user portal is on a tab in one of it's layouts.)

      The Users portal holds a list of users. When the create new user script is run, it creates a new record in the users table and uses the data to create a new account for the file. This all works well except for the possibilty of creating two Administrators, this is a security issue as this privilege alone has price edit access.

      I am hoping this is something simple I'm overlooking, I'll keep trying

      David:)

       

    • David583

      Got It!!!!!!!!!!!!

      It was something simple I overlooked after all

      I needed a summary of your calculation, now I can test the summary and it works fine.

      Thanks again for your help

      David:)

    • Sorbsbuster

      How does the account get created?  I let users create accounts for their systems.  I catch the User name they want, the password they want, and the Access Level (Priviledge Set) they want.  They can chose 1, 2,  or 3 (as explained in the dialogue.)  A script checks for what Access Level they asked for, and adds the user name to that Privilege set.  The access level 4 (administrator) is not open to them.

      How do you give the first administrator the privilege?  Does that come with the file?  In which case you can simply ban anyone creating another one (see above).  Do they have to create the first one themselves? In which case mark that creation in the Preferences file, and use the script to check for that.  Once it's created, "No more administrators can be created, thank you"

    • David583

      I was using two seperate buttons with script parameters. With staff turnover in mind I wanted them to be able to change the administrator easily without my help.

      I think you're right though, I fell into the trap of overthinking it.

      A simple flag during the script will only take 1 field where mine now takes 2 and more processing. The reverse in deleting the administrator is simpler too. Sorry I was too quick with the tick, just got excited when it worked. I'll change it to your method now Embarassed