10 Replies Latest reply on Jan 10, 2015 11:35 AM by philmodjunk

    Relating a Username to their specific Account Details

    AbrahamHayek

      Title

      Relating a Username to their specific Account Details

      Post

      Hello, quick summary of my setup, I'm having my customers be required to login into web direct in order to see a specific form in which they place their orders and submit.  Right now anyone who calls us, we set them up with a username and password to login into the web direct portal.  I want to add a feature that allows these users to be able to see their account details and their past orders.

      I figured out how to relate projects/orders to a specific contact in the database, but I do not see how I can relate a username that I setup in File > Manage > Security to their specific contact details.

      Any help is appreciated!

        • 1. Re: Relating a Username to their specific Account Details
          philmodjunk

          That depends on what you mean by "relate".

          You can set up a "lock expression" in Manage security that limits a user to only being able to see records they created. Is that what you want?

          If you have a field named CreatedBY that auto-enters the creation account name, you can use this lock expression to limit access to records in that table:

          Get ( AccountName ) = CreatdBY

          Note that when you set up this type of record level access control, any find performed by the user or a script will automatically omit "no access" records from the resulting found set. You can thus use a script to perform a find when the user first accesses a layout to limt the visible found set of records to just those for which they are permitted to view.

          • 2. Re: Relating a Username to their specific Account Details
            Mark_M

            >

            Never mind. smiley

            >>>>

             

             

             

            • 3. Re: Relating a Username to their specific Account Details
              AbrahamHayek
               @PhilModJunk that's exactly what I am trying to do, allowing a user to see records they have created/submitted.  I went into File > Manage > Security and I cannot see where I can create or input this lock expression.  Each project that is submitted to me does have a created by, but again this is just in terms of username, no relationship to their actual contact information in the database. Your help is appreciated, looking forward to your reply.
              • 4. Re: Relating a Username to their specific Account Details
                Mark_M

                >

                Phil will correct me if I'm wrong (Hopefully), but I think it is...

                You will maintain a field on the Customer Table of called "CreatedBy" which is the login name of customer uses.

                       
                • File Menu open Manage open Security
                •      
                • Select the Privilege Sets Tab
                •      
                • Select one of the three default sets (probably Data Entry Only) as a starting point.
                •      
                • Click the copy then select the Edit button
                •      
                • In the Privilege Set Name field rename the set to something that makes sense to you, call it "Customer" if you will.
                •      
                • Under Record, select "Custom Privileges"
                •      
                • For each table you will see View|Edit|Create|Delete|Field Access columns
                •      
                • Below in the display you will see a drop down list under each column.
                •      
                • Select a Table Row, then click (For example) the View drop down list and select "Limited"
                •      
                • That opens a standard calculation box where you can set the "Get(AccountName) = CreatedBy"
                •      
                • Repeat for and View/Edit tables that the customer will need to view or change.

                 

                I've done it in the past, but I'd recommend not doing it in your live database first.  Play around with it in a copy that you can throw away after you get the feel for how things will work.

                >>>>

                 

                • 5. Re: Relating a Username to their specific Account Details
                  AbrahamHayek

                  I did that, but I still feel there is a missing piece. When a user logs into the database via web direct, the first layout they go to has 3 options, one for ordering a print job, one for having their information on our website, and the 3rd being the one where they can "View Account and Past Orders".

                  The 3rd button currently set up with a script that just entails a "Go to Layout," in which I am taking them to a layout that shows contact information fields and under that past projects.  Currently usernames are based on First+LastName, which is what the CreatedBy will show on each project order.

                  Now at the moment when someone clicks the third option the contact information displayed will just literally be the last contact in that table, and their projects, so nothing related to the contact that has logged in.  How do I match the information that loads for the username to their correct contact details which will automatically show their related projects.

                  The missing piece is in my thinking some sort of script that does a Find with the logic of username = Name+LastName then open the layout with that persons information.  I hope that clarifies what I am trying to do.

                  Look forward to your response, thanks so much

                  • 6. Re: Relating a Username to their specific Account Details
                    philmodjunk

                    To repeat from my first post: ANY FIND performed by the script or the user will automatically omit any records that are "no access" for the current user.

                    Also, be careful to distinguish between user names and account names. They aren't necessarily the same thing.

                    You can set up a scripted find that either finds all non-blank records or all records with their specified name in the specified field.

                    The first relies on security settings to produce the same results as the second script does explicitly.

                    For examples of scripted finds, see: Scripted Find Examples

                    • 7. Re: Relating a Username to their specific Account Details
                      AbrahamHayek

                      I understand what you are saying, but my scenario/question is how do I tell my FM Database, that when for example PhilMod logs in via web direct, and then chooses the "View Account and Past Orders" button, to go to the specified layout, but not only that have the layout load the information for Phil Mod (which would be your first name and last name in my contacts table).  The layout I already have already pulls the related project based on the contact, but what I cannot figure out is how to say load the information of the person who logged in.

                      So that is why initially I was asking how do I say the user PhilMod is related to the contact Phil Mod in my contacts table.

                      Thank you

                      • 8. Re: Relating a Username to their specific Account Details
                        Mark_M

                        >

                        File Menu | Manage | Database | Relationships Tab

                        Drag the CreatedBy field from the Customer table to the CreatedBy field in the Orders table.  This creates what is called a "Join" between the Customer table and the Orders table.

                        If you use the security setup previously described then the only Customer record that can be viewed will be the one for the person currently logged in.  If the related orders are being shown then only those orders should be displayed.

                        *****************************************************

                        BTW - I my opinion, and it's just that.  Don't base the CreatedBy field based on a calculation (First Name + Last Name), if you ever have two Customers with the same name that will cause problems.  I think you might be better off in the long run to manually enter it with the field options set to "Unique" so that no duplication of the CreatedBy field can occur for two different customers.

                         

                        >>>>

                        • 9. Re: Relating a Username to their specific Account Details
                          AbrahamHayek

                          Thanks for your help guys, so the Find script I came up with which works perfectly is below:

                          Go to Layout ["My Account and Previous Orders" (T05_Contacts)]
                          Enter Find Mode []
                          Set Field [T05_Contacts::Name_Full; Get ( AccountName )]
                          Perform Find []

                          With the issue of potentially two people having the same first and last name, I am deciding that I should go with using email as account names for the web direct login.  So I did the following:

                          1) I went and made a limited access for records: Get ( AccountName )  = T05_Contacts::Email

                          2) I changed the above script to: 

                          Go to Layout ["My Account and Previous Orders" (T05_Contacts)]
                          Enter Find Mode []
                          Set Field [T05_Contacts::Email; Get ( AccountName )]
                          Perform Find []

                          3) Made a test contact with Name being Scott Brown and this same contact with email: scottbrown@gmail.com

                          4) File | Manage | Security | >> New Account Name = scottbrown@gmail.com

                          Now when I log in with this user in web direct and click the button to go to "My Account and Previous Orders" I am getting a Find Criteria not found, even though this account name scottbrown@gmail.com does have a contact in T05_Contacts with email field = scottbrown@gmail.com

                          I changed back everything to do with email back to name_full and it works beautifully, but I want it to work with email, what am I doing wrong?

                          • 10. Re: Relating a Username to their specific Account Details
                            philmodjunk

                            Hmm, but people have been known to change their email address. And then you have a problem where you have to update both related children and parent records identically with the new email address or you lose the link between them. This could also happen if an email is entered incorrectly and you only discover the error after a number of related records exist.

                            It would be better to link your records by an auto-entered serial number and use the Account name as a way to look up that value. (Perform a find on the parent table using the user's current account name, then use the relationship (go to related records) or the value of the record's primary key (auto-entered serial number of Get ( UUID ) ) to find the records you want in your found set.

                            Your Lock expression could also refer to this ID instead of an account name if you modify your design to record the user's ID in a field instead of their account name.