1 Reply Latest reply on Feb 2, 2015 5:23 AM by philmodjunk

    Filter record on account basis so that each user can view only his/her record.

    Vicspidy

      Title

      Filter record on account basis so that each user can view only his/her record.

      Post

      I've two tables ARTIST and RECORD. I'm using WebDirect on my LAN. Each artist in my team have to enter in the RECORD table what he's done every day. They can create multiple records for a day. Now I only want that when a user logs in, he only sees his record (I've created a layout based on ARTIST table and I'm using portal to filter record for that artist on a specific day).

                                                 Now The irony here is that I've filtered the record by studying a file (I download it from some site). But I'm not able to understand how it's working.Here is what I've setup so far...

                                            In file options (File Menu) I've a script trigger on OnFirstWindowOpen, where I'm setting GCurrentUser(Global Field) to Get(AccountName). I forgot to mention I've also a system table where there's only one field GCurrentUser.

                                           In the Layout setup I've a script trigger on OnLayoutEnter. Is is like this

                                          Set Error Capture [On]

                                          If [Get(CurrentPrivilegeSetName)= "[Full Access]"]

                                              Show All Records

                                          Else

                                              Show/Hide Toolbars [Hide]

                                              Enter Find Mode[]    // Nothing specified in here

                                              SetField[artist::c_user;Get(AccountName)]

                                              Perform Find []  // Nothing specified here

                                           Endif

      Then in Manage Security I've defined a Privilege Set called Artist where for the artist table in the view section I've set it to Limited and for the calculation I've written this 

                                            Get(AccountName)=system:gCurrentUser

      and it is giving me what I want but i don't know how maybe becauseI've not understood how Gobal field works.

        • 1. Re: Filter record on account basis so that each user can view only his/her record.
          philmodjunk

          How is c_user defined? That c is a naming convention for a calculation field. I'd define a text field in Records that auto-enters the creator's account name.

          If so, I don't see any need for the gCurrentUser field. (Any time that you need the name of the current user's account, just use Get ( AccountName )). You could setup a lock expression for the Records table in Manage | Security that reads like this:

          Get ( AccountName ) = user

          To control access to the artist table on a record by record basis.

          Your script works to find the right record(s) on the artist table. If you walk through the steps each step set's up a find request just like you would manually and then finds the artist record(s) with that account name.