1 Reply Latest reply on Dec 8, 2011 10:17 AM by philmodjunk

    Pass a Username

    PeterDowns

      Title

      Pass a Username

      Post

      Hi

      In my database users log on and I use the FMP security to control levels etc. I reference the username of people with the GET command. When users log on they only see their own projects unless they are an administrator.

      When someone creates a new project they take ownership by an Owner drop down box (containing their full names). Everything is cool, the only interesting new proposition that I didn't think of, is that some people enter projects on behalf of others and assign ownership to that person by the drop down box.This is fine and works however if the recipient of the projects logs on to view their projects they don't see the projects that have been entered on their behalf. 

      The reason for this is

      _ when a new record is created the username is added to the field "record_created_by" (this is the username of the person logged on) see pic below

      _the "Owner" drop down box put a user's full name into the "Owner" field in the same projects table (this may not necessarily be the person logged on).

      So the person who is logged on has his username in the "record_created_by" field for someone else's project.

      Username is also different from fullname: Username is structured as - "john.smith", full name obviously - "John Smith"

      What I need to do is pass the username of the person selected in the "owner" drop down box to the "record_created_by" field in the projects table when someone else is entering projects on behalf of other people.

      Obviously the easy way out is to convert the Owner ddbox to usernames and pass the value but I rather keep it as full names. I thought a script trigger on the drop down box on modification for placement. I have tried a 'insert calculated result' script but no luck.

      All user details are stored in a related contacts table.
      Any suggestions on how to approach this.

      Cheers

      Peter

      Screen_Shot_2011-12-08_at_3.58.59_PM.png

        • 1. Re: Pass a Username
          philmodjunk

          First, using personal names to record ownership may cause a few problems as names are not unique and people change their names from time to time. You may want to set up a table of users with names and a serial ID number, then use the serial ID number to record ownership.

          Beyond that, it looks like you should set up a trigger on the owner ship field so that it can compare the auto-entered account name to the the data specified in the drop down and update the auto-enter field to match if they aren't the same. (or just dispense with the auto-entered field and just use the one where they specify ownership, making it a required field so that users can't leave it blank.)