10 Replies Latest reply on Mar 7, 2012 3:58 PM by philmodjunk

    Adding a third button to this script to re-login then new record request

    MarcMcCall

      Title

      Adding a third button to this script to re-login then new record request

      Post

      I would like to add a third button to this script that gives the user the option to create a new record after a re-login if no SSN # is found.  The script opens a search window that has a search field for a SSN#.  I have the layout set to only allow unique Data in that field so there are no duplicate SSN'# in the Account records.  If there is a SSN# that matches, they can select that record from the search popup, then create a new related interview record from a button on the Accounts layout.  If no SSN# match is present this is where I want the 3rd button to come in, I want them to have to re-login then a new record request.  I've been messing with this all day, and can't get it.

      The first part and end of the script in place now, that searches for the SSN.

      • Allow User Abort [ Off ]
      • Set Error Capture [ On ]
      • #--------------------------------------Performs the script that searches the Accounts Module
      • Go to Layout [ “L10_ACCOUNTS_Data_Entry” (T01_ACCOUNTS) ]
      • Show All Records
      • Perform Script [ “ (0402) Account SSN # Search” ]
      • Enter Find Mode [ ]
      • Paste [ T01_ACCOUNTS::ClientsSocialSecurityNumber ] [ Select ]
      • Perform Find [ ]

      The (402)  Account SSN # Search script.

       

      • Set Variable [ $portal; Value:Get ( ActivePortalRowNumber ) ]
      • Set Error Capture [ On ]
      • #--------------------------------------Sets a variable of the current window name
      • Set Variable [ $$Window_Name; Value:Get (WindowName) ]
      • #--------------------------------------Changes the current window to read "Searching..."
      • Set Window Title [ Current Window; New Title: "Searching..." ]
      • #
      • #--------------------------------------Creates a new window for the Account search.
      • #
      • New Window [ Name: "Account SSN # Search"; Height: 1; Width: 1; Top: 100; Left: 100 ]
      • #--------------------------------------Freezes the window for visual purposes
      • Freeze Window
      • #--------------------------------------Denies the user the privilege of aborting the script and then Hides and Locks the status area
      • Allow User Abort [ Off ]
      • Show/Hide Status Area [ Lock; Hide ]
      • #
      • #--------------------------------------Goes to the Account Popup screen, designed for searching.
      • #
      • Go to Layout [ “L13_ACCOUNTS_Search_Popup Copy” (T01_ACCOUNTS) ]
      • #--------------------------------------Enters Browse Mode and then sets the title of the button to the "Find"
      • Enter Browse Mode
      • Set Field [ T16n_census_PREFERENCES||id_constant|::g_search_button_status; "Find" ]
      • #
      • #--------------------------------------Enters Find Mode, goes to the Accounts SSN# field and pauses
      • Enter Find Mode [ ]
      • Refresh Window [ Flush cached join results ]
      • Adjust Window [ Resize to Fit ]
      • Go to Field [ T01_ACCOUNTS::ClientsSocialSecurityNumber ]
      • Show Custom Dialog [ Title: "Account SSN # Search"; Message: "Please enter the persons SSN # and perform search"; Buttons: “OK” ]
      • Pause/Resume Script [ Indefinitely ]
      • #
      • Perform Find [ ]
      • If [ Get(LastError) = 401 ]
      • #--------------------------------------If no records were found, a dialog gives the user the opportunity to retry
      • Show Custom Dialog [ Title: "Alert!"; Message: "No records were found. Would you like to modify your find?"; Buttons: “Modify”, “Cancel” ]
      • If [ Get(LastMessageChoice) =1 ]
      • Loop
      • Enter Find Mode [ ]
      • Go to Field [ T01_ACCOUNTS::ClientsSocialSecurityNumber ]
      • Pause/Resume Script [ Indefinitely ]
      • Perform Find [ ]
      • If [ Get(LastError) = 401 ]
      • Show Custom Dialog [ Title: "Alert!"; Message: "No records were found. Would you like to modify your find?"; Buttons: “Modify”, “Cancel” ]
      • If [ Get(LastMessageChoice) = 2 ]
      • Close Window [ Current Window ]
      • Set Window Title [ Current Window; New Title: $$Window_Name ]
      • Commit Records/Requests [ Skip data entry validation; No dialog ]
      • Exit Script [ ]
      • End If
      • End If
      • Exit Loop If [ Get(FoundCount) ≥ 1 or Get(LastMessageChoice) = 2 ]
      • End Loop
      • #--------------------------------------If the user does not wish to retry, the search window closes and orginal window is set back to the orginal title
      • Else If [ Get(LastMessageChoice) =2 ]
      • Close Window [ Current Window ]
      • Set Window Title [ Current Window; New Title: $$Window_Name ]
      • Commit Records/Requests [ Skip data entry validation; No dialog ]
      • Exit Script [ ]
      • End If
      • End If
      • #--------------------------------------Because there is not a found count based on the user's find, the button changes from "Find" to "Select" for the user to select a project
      • Set Field [ T16n_census_PREFERENCES||id_constant|::g_search_button_status; "Select" ]
      • #--------------------------------------Sorts the records alphabetically
      • Sort Records [ Specified Sort Order: T16_CENSUS::sort; ascending T16_CENSUS::Census_Name; ascending ] [ Restore; No dialog ]
      • Go to Record/Request/Page [ First ]
      • #--------------------------------------Pauses for the user to choose
      • Pause/Resume Script [ Indefinitely ]
      • Copy [ T01_ACCOUNTS::ClientsSocialSecurityNumber ] [ Select ]
      • #--------------------------------------Once the select button has been pressed for a certain Account, the appropriate information is set in variables
      • Go to Next Field
      • #--------------------------------------The search window is closed and the orginal window's title is set to the orginal text
      • Close Window [ Current Window ]
      • Set Window Title [ Current Window; New Title: $$Window_Name ]
      • #
      • If [ not IsEmpty ($$CC) ]
      • Exit Script [ Result: $Copy_CC ]
      • Else
      • Exit Script [ Result: $Copy_ID_Project ]
      • End If
      • Commit Records/Requests [ Skip data entry validation; No dialog ]

       

       

       

       

       

       

       

        • 1. Re: Adding a third button to this script to re-login then new record request
          philmodjunk

          By "re-login" do you meant log back into the database with a different password? Why do you need to do that?

          Additional generial comments on your script:

          Comment 1)

          Go to Field [ T01_ACCOUNTS::ClientsSocialSecurityNumber ]
          Show Custom Dialog [ Title: "Account SSN # Search"; Message: "Please enter the persons SSN # and perform search"; Buttons: “OK” ]
          Pause/Resume Script [ Indefinitely ]

          could be replaced with an input field in the custom dialog for entring the social security number. Use a text field with Global Storage and your script can enter find mode and perform the find without pausing after you dismiss the custom dialog instead of pausing twice--once to ask for the social security number and one to pause in find mode so that they can enter it.

          Comment 2)

          Copy/paste are script steps best avoided unless you have no alternative. Use set variable in place of Copy and set field in place of paste as this will leave any data copied to the clipboard by the user intact and set field/set variable are steps that do not require the referenced field to be physically present on the layout as is necessary for copy and paste. (Take the field off the layout in a future layout update and the script fails to work without displaying any error message that this it failed to copy or paste the value.)

          • 2. Re: Adding a third button to this script to re-login then new record request
            MarcMcCall

            "By "re-login" do you meant log back into the database with a different password? Why do you need to do that?"

            The people that use the the original program have a tendency to leave it open at the Admissions desk and someone else may jump on the pc to do an interview, so they have to physically ask around who took it later on, so I want to remove the ability to use the create new record via the menu and status area, and use a scripted button that will get the creation user info.  So far, I actually got it working to a point about 12 last night, but if the user hits cancel on the re-login dialog window, the script continues, which i don't want, and I'd rather have it so they don't have to close the whole file and restart.  As far as the input field, I'd like to leave it with the popup window because the DB has only been inlace for 1.5 years, and there is a lot of data in there that is incomplete because they used to use excel to run just the Census part, not all of the interviews and intakes, so the search popup has a name field on it also, so if there is no SSN#, they can still use those fields to perform the search and then update the record. I also want to slow down a lot of the unnecessary record creations due to someone just messing around.  The people at the front desk don't have permission to delete records because a disgruntled employee deleted a bunch of stuff.  It is a drug treatment center with "recovered"addicts working there, so they aren't always as professional as a normal office might be.

             

            The copy and paste.  I actually had that working at one point with the set variable but messed the script up so bad trying to get the other part working I scraped it and started over, and couldn't remember how to get it working again, so I said screw it and went to the copy paste. I used an already stepped script in another solution and copied it and modified it, so I didn't actually write the script myself, just modified one to do what I wanted.

             

            So where I'm at now, I have the 3rd button working, but I need to figure out how to prevent it from creating a new record if the re-login is canceled, and how to replace the copy paste.  FYI I set the script to run with full privileges, not sure if that is right, but think so since I took away the ability to create records via the menu.  If you need, I can paste in the new mods I made last night.

            • 3. Re: Adding a third button to this script to re-login then new record request
              philmodjunk

              if the user hits cancel on the re-login dialog window, the script continues, which i don't want, and I'd rather have it so they don't have to close the whole file and restart.

              Do you use Get ( lastMessageChoice ) to check what button was clicked. Since I don't know the current version of the script you posted above, I can't specifically identify the number to use but you use this in an If step with 1, 2 or 3 to detect whether button 1, button 2 or buttn 3 was clicked and if cancel is clicked, you should be able to detect that and do what is needed to respond to that click. This could be as simple as:

              If [Get ( LastMessageChoice ) = 3 // cancel was clicked ]
                  Exit Script // or possibly Halt script if you have pending scripts that need to be killed off at this point.

              End If

              As far as the input field, I'd like to leave it with the popup window because the DB has only been inlace for 1.5 years, and there is a lot of data in there that is incomplete because they used to use excel to run just the Census part, not all of the interviews and intakes, so the search popup has a name field on it also, so if there is no SSN#, they can still use those fields to perform the search and then update the record.

              You certainly do not have to change your design, but I must point out that show custom dialog can handle all of this and it does not require any changes to your existing file, just the addition of a global field for each field used to collect search criteria. So unless you need more than three input fields, show custom dialog can handle it. It's also possible to use New Window to create your own pop up dialog with value lists and as many fields for specifiying search criteria as needed. Either way, your user interface becomes a tad smoother as you only have to click once to complete your search of the existing table instead of twice.

              I also want to slow down a lot of the unnecessary record creations due to someone just messing around.

              I suggest that you use an auto-enter setting to capture the user's account name each time a record is created. That way folks can be held accountable if "just messing around" is generating a lot of unecessary records. You might also separate the search process from the record creation process so that searching for a record results in the user being asked a second question: Do you want to create a new record with Ok and Cancel so that a user can go "oops I didn't want to do that, clicks cancel and they are returned to their starting layout and no record is created.".

              • 4. Re: Adding a third button to this script to re-login then new record request
                MarcMcCall

                My last reply didn't post for some reason, and the IRS just pee'd in my cornflakes so I'll repost tomorrow. Thanx for all the help PhilMod...

                • 5. Re: Adding a third button to this script to re-login then new record request
                  MarcMcCall

                  Well after a night of thinking about this, this is how I'd like to get it working.

                  Click the new record button on layout to start script. the dialog box opens and says enter SSN # and click search. If no SSN# matches custom dialog with 3 buttons. 1. New record, 2 Cancel, 3 Modify search ( any order ).. If cancel no new record request close popup window and stay on accounts layout. If modify , modify. If New Record, capture the SSN# they typed in but wasn't found and go to the Account layout, Re-login, new record request and cash the SSN# they typed in.  If Re-Login is canceled end script and just stay on the Account layout. If there was one found, the "search" button on the popup should already have changed to select on the popup window which resumes the script when clicked, captures the SSN# and goes to the Accounts layout after closing the popup window performs the find with the SSN#. If the name fields are use in the search and "select" button resumes use the names in the name fields for the perform find Name_First, Name Last to load the existing record. 

                   

                  • Allow User Abort [ Off ]
                  • Set Error Capture [ On ]
                  • #--------------------------------------Performs the script that searches the Contacts Module
                  • Go to Layout [ “L10_ACCOUNTS_Data_Entry” (T01_ACCOUNTS) ]
                  • Show All Records
                  • Set Variable [ $portal; Value:Get ( ActivePortalRowNumber ) ]
                  • Set Error Capture [ On ]
                  • #--------------------------------------Sets a variable of the current window name
                  • Set Variable [ $$Window_Name; Value:Get (WindowName) ]
                  • #--------------------------------------Changes the current window to read "Searching..."
                  • Set Window Title [ Current Window; New Title: "Searching..." ]
                  • #
                  • #--------------------------------------Creates a new window for the Project search.
                  • #
                  • New Window [ Name: "Account SSN # Search"; Height: 1; Width: 1; Top: 100; Left: 100 ]
                  • #--------------------------------------Freezes the window for visual purposes
                  • Freeze Window
                  • #--------------------------------------Denies the user the privilege of aborting the script and then Hides and Locks the status area
                  • Allow User Abort [ Off ]
                  • Show/Hide Status Area [ Lock; Hide ]
                  • #
                  • #--------------------------------------Goes to the Account Popup screen, designed for searching.
                  • #
                  • Go to Layout [ “L13_ACCOUNTS_Search_Popup Copy” (T01_ACCOUNTS) ]
                  • #--------------------------------------Enters Browse Mode and then sets the title of the button to the "Find"
                  • Enter Browse Mode
                  • Set Field [ T16n_census_PREFERENCES||id_constant|::g_search_button_status; "Find" ]
                  • #
                  • #--------------------------------------Enters Find Mode, goes to the Accounts SSN# field and pauses
                  • Enter Find Mode [ ]
                  • Refresh Window [ Flush cached join results ]
                  • Adjust Window [ Resize to Fit ]
                  • Go to Field [ T01_ACCOUNTS::ClientsSocialSecurityNumber ]
                  • Show Custom Dialog [ Title: "Account SSN # Search"; Message: "Please enter the persons SSN # and perform search, or use name fields"; Buttons: “OK” ]
                  • Pause/Resume Script [ Indefinitely ]
                  • #
                  • Perform Find [ ]
                  • If [ Get(LastError) = 401 ]
                  • #--------------------------------------If no records were found, a dialog gives the user the opportunity to retry
                  • Show Custom Dialog [ Title: "Alert!"; Message: "No records were found. Would you like to modify your find?"; Buttons: “Modify”, “Cancel”, “New Record” ]
                  • If [ Get(LastMessageChoice) =1 ]
                  • Loop
                  • Enter Find Mode [ ]
                  • Go to Field [ T01_ACCOUNTS::ClientsSocialSecurityNumber ]
                  • Pause/Resume Script [ Indefinitely ]
                  • Perform Find [ ]
                  • If [ Get(LastError) = 401 ]
                  • Show Custom Dialog [ Title: "Alert!"; Message: "No records were found. Would you like to modify your find?"; Buttons: “Modify”, “Cancel”, “New Record” ]
                  • If [ Get(LastMessageChoice) = 2 ]
                  • Close Window [ Current Window ]
                  • Set Window Title [ Current Window; New Title: $$Window_Name ]
                  • Commit Records/Requests [ Skip data entry validation; No dialog ]
                  • If [ Get(LastMessageChoice) = 3 ]
                  • Close Window [ Current Window ]
                  • Set Window Title [ Current Window; New Title: $$Window_Name ]
                  • Commit Records/Requests [ Skip data entry validation; No dialog ]
                  • End If
                  • End If
                  • End If
                  • Exit Loop If [ Get(FoundCount) ≥ 1 or Get(LastMessageChoice) = 2 ]
                  • End Loop
                  • #--------------------------------------If the user does not wish to retry, the search window closes and orginal window is set back to the orginal title
                  • Else If [ Get(LastMessageChoice) =2 ]
                  • Close Window [ Current Window ]
                  • Set Window Title [ Current Window; New Title: $$Window_Name ]
                  • Commit Records/Requests [ Skip data entry validation; No dialog ]
                  • Exit Script [ ]
                  • Else If [ Get(LastMessageChoice) =3 ]
                  • Close Window [ Current Window ]
                  • Set Window Title [ Current Window; New Title: $$Window_Name ]
                  • Commit Records/Requests [ Skip data entry validation; No dialog ]
                  • Go to Layout [ “L10_ACCOUNTS_Data_Entry” (T01_ACCOUNTS) ]
                  • // Re-Login [ ]
                  • New Record/Request
                  • Exit Script [ ]
                  • End If
                  • End If
                  • #--------------------------------------Because there is not a found count based on the user's find, the button changes from "Find" to "Select" for the user to select a project
                  • Set Field [ T16n_census_PREFERENCES||id_constant|::g_search_button_status; "Select" ]
                  • #--------------------------------------Sorts the records alphabetically
                  • Sort Records [ Specified Sort Order: T16_CENSUS::sort; ascending T16_CENSUS::Census_Name; ascending ] [ Restore; No dialog ]
                  • Go to Record/Request/Page [ First ]
                  • #--------------------------------------Pauses for the user to choose
                  • Pause/Resume Script [ Indefinitely ]
                  • // Copy [ T01_ACCOUNTS::ClientsSocialSecurityNumber ] [ Select ]
                  • #--------------------------------------Once the select button has been pressed for a certain Account, the appropriate information is set in variables
                  • Go to Next Field
                  • #--------------------------------------The search window is closed and the orginal window's title is set to the orginal text
                  • Close Window [ Current Window ]
                  • Set Window Title [ Current Window; New Title: $$Window_Name ]
                  • #
                  • If [ not IsEmpty ($$CC) ]
                  • Exit Script [ Result: $Copy_CC ]
                  • Else
                  • Exit Script [ Result: $Copy_ID_Project ]
                  • End If
                  • Commit Records/Requests [ Skip data entry validation; No dialog ]
                  • 6. Re: Adding a third button to this script to re-login then new record request
                    philmodjunk

                    Where does the above script fail for you?

                    By "re-login" do you want to re-log into the database under a different password or do you have a different procedure in mind when you say you want them to "re-login"?

                    Get(LastError) = 401

                    401 is not the only possible error code that can be returned by a failed find. If the user leaves all fields blank, for example an error code for missing criteria is returned. You may want to use a test that checks to see if the error code is not zero or use get ( FoundCount ) to determine whether or not your find was successful in finding a record.

                    You can capture the SSN entered (If one was entered)

                    with Set Variable [$SSN ; value: T01_ACCOUNTS::ClientsSocialSecurityNumber ]

                    if you place it just before the Perform Find [] step.

                    • 7. Re: Adding a third button to this script to re-login then new record request
                      MarcMcCall

                      The "Get(LastError) = 401" that was actually part of the original script, it only appears if no data is found when something is typed in, if nothing is typed in, it shows all accounts, I think in account name descending. The search seams to work fairly good, if you type the whole # in and no match, it returns the error message.  If you type 2 number in, it returns a search with all Records containing those numbers.  As far as login, if its the same person who is logged in, they just log back in, if someone else jumps on the computer while it was left open, it forces them to login to get the correct user when the new record is created.

                      I think that answers your questions.

                      • 8. Re: Adding a third button to this script to re-login then new record request
                        philmodjunk

                        It doesn't.

                        Where does the last version of your script fail for you?

                        If you have this working to your satisfaction, then there is no need to continue this thread.

                        • 9. Re: Adding a third button to this script to re-login then new record request
                          MarcMcCall

                          When I try i with the re-login enabled.  when I hit cancel on the login dialog, it continues the script with the new record request.  I would like it to cancel and just go to the account layout with no new record request.

                          • 10. Re: Adding a third button to this script to re-login then new record request
                            philmodjunk

                            Is this the part of the script where you have trouble when you enable the Re-login?

                            Close Window [ Current Window ]
                            Set Window Title [ Current Window; New Title: $$Window_Name ]
                            Commit Records/Requests [ Skip data entry validation; No dialog ]
                            Go to Layout [ “L10_ACCOUNTS_Data_Entry” (T01_ACCOUNTS) ]
                            // Re-Login [ ]
                            New Record/Request
                            Exit Script [ ]

                            This was copied from the most recent post where you listed your script.

                            Note that you have New Record/Request as the next step after Re-LogIn before the exit script exits this script. It would seem you need to rewrite this portion of your script located immediately after the Re-Login step as your current scritp creates a new record and leaves you on the current layout. It would seem you need to change this to:

                            Close Window [ Current Window ]
                            Set Window Title [ Current Window; New Title: $$Window_Name ]
                            Commit Records/Requests [ Skip data entry validation; No dialog ]
                            Go to Layout [ “L10_ACCOUNTS_Data_Entry” (T01_ACCOUNTS) ]
                            Re-Login [ ]
                            Go to layout [//specify the layout you want to take them to here]
                            Exit Script[ ]