5 Replies Latest reply on Dec 30, 2011 9:49 AM by philmodjunk

    Script to Direct Login to Specific Record, based on Account Name in IWP Help.

    RyanCantor

      Title

      Script to Direct Login to Specific Record, based on Account Name in IWP Help.

      Post

      Ok. So I have a database of employees. Each employee will have an account name, this is dictated by a field in their employee record called username. 

       

      When an employee logs into IWP, I want it to automatically bring them to their page. So I've been doing, Find, Username = Get(AccountName) 

       

      However this isn't working at all. I am maintaining a very restrictive enviornment, so by which once I get them only to their record, they won't be able to move onto another record, etc. But in other IWP Layouts, they will be able to see their employees, who are also in the employee table (self-relationship). 

      If I restrict their ability to only view records, to Username=Get(AccountName), that works and they login and can only see their page. But unfortunately, they can't see any of their employees because at the top level security I'm only allowing them to see themselves. 

       

      My goal is to let them see all employees, based on the layout I set for them, but when they login need them to go to a specific record basically.

       

      I've tried finds, i've tried go to record by calculation, i've tried doing it the bad unprofoessional way of entering find mode, set field by name, and perform find, and still nothing is working. 

       

      Any help?

        • 1. Re: Script to Direct Login to Specific Record, based on Account Name in IWP Help.
          philmodjunk

          So I've been doing, Find, Username = Get(AccountName)

          Better take a closer look that method.

          If you have a field in the table that records the account name and it's named "username", then this script should work:

          #Script should be performed on layout based on YourTable
          Enter Find Mode [] //clear the pause check box
          Set Field [YourTable::UserName ; get ( AccountName ) ]
          Set Error Capture [on]
          Perform Find []

          • 2. Re: Script to Direct Login to Specific Record, based on Account Name in IWP Help.
            RyanCantor

            The problem I am encountering is that it seems to be blowing right by the "Enter Find Mode []"

             

            When I try take it apart step by step to see what it is doing, If I click pause, it does stop in Find Mode, however, when I manually enter the account name the perform find is grayed out, never have seen this before. 

             

            If I enter the IWP layout normally, with the same account name (without the startup script) and manually click Perform Find, I can perform the find I want to without issue, so I know the permissions are set ok, as this account can perform finds, however, there is clearly something wacky. 

             

            I'm attaching my open script. After it goes to "Web Dashboard" it just is bringing up a random record that doesn't match the account name. 

             

            I really appreciate your second set of eyes on this. 

             


             

            • 3. Re: Script to Direct Login to Specific Record, based on Account Name in IWP Help.
              philmodjunk

              Why do you need it to stop in find mode?

              The script is not written to do that. It enters find mode, specifies the account name as criteria and performs the find. No pause in find mode needed.

              The assumption behind this script is that the account names in Manage Security match the text in the UserName field in your table.

              Looking at your script...

              Why do you store passwords in a field in contacts? Why do you use Replace Field Contents to clear the field? Why do you have this step twice?

              • 4. Re: Script to Direct Login to Specific Record, based on Account Name in IWP Help.
                RyanCantor

                Ok. I figured it out. 

                Exporting and looking at the whole script pointed to the problem. 

                Also just to answer your points, and then I'll explain the problem just for resolution's sake. 

                - I don't store pw's. I actually just have two dummy fields, so that a bottom level user can click "change password" and it opens a layout on the same record that allows them to type in their old pw, and new pw, and then click change. IN the change script I wipe the fields after the change is complete so there isn't a record of the new PW, that middle level users would have access to. 

                - There is a field, not visibility to bottom level users that is triggered when a top level user creates the account in a button on the record. The button creates the account, sets a generic pw, and triggers a field to be marked as "Yes". As in "Yes" the PW needs to be changed. 

                - Upon login on the bottom level user, it checks to see if that field is marked "Yes", and if it is, it re-directs them to a screen to change their password. When they do, it also sets the field to "no" so that next time they login, it doesn't prompt them to change their password.

                 

                The issue is that Perform Script "Remove No Access Listings" and Enter Browse mode at the bottom of the script were too low on the list. The should be been put before the End If, under the Go To Layout "Splash Page". 

                 

                Basically, it was working, but because I was doing another find, and entering browse mode at the end, what I visually saw everytime was something different. I think that makes sense. I got it working 100% with the way you and I knew should work. 

                 

                Thanks for taking the time. Its totally a case of a second set of eyes, and a lot of thinking and looking outloud. 

                 

                Ryan

                • 5. Re: Script to Direct Login to Specific Record, based on Account Name in IWP Help.
                  philmodjunk

                  I don't store pw's. I actually just have two dummy fields,

                  Ok, but you don't need to do it twice and you don't need to use replace field contents. You should use Set field instead to clear the field. Replace Field Contents modifies the specified field for every field in your current found set so this could produce very unexpected results for you and could slow the execution of your script as it waits for multiple records to be updated by this step.