3 Replies Latest reply on Sep 19, 2013 2:51 PM by philmodjunk

    Button to perform Find against current user and name_first name_last

    RayGerman

      Title

      Button to perform Find against current user and name_first name_last

      Post

           Hello,

           I am just getting into scripts with filemaker and have a relatively simple problem. I have created a script button that automatically goes to a layout I created and finds the record for the user with the first name Don.

           I would like to perform a more advanced script to Get the current account name and perform a find on the users name_first & name_last.

           My table has a concatenated field for name_first & name_last... so only need to know how to have the script search the current username logged into the database.  

           Any thoughts?

           Thanks,

           Ray

            

            

      ScreenShot.png

        • 1. Re: Button to perform Find against current user and name_first name_last
          philmodjunk

               Get ( accountName ) will return the current account name.

               That can be used with one of the scripted find examples found here: Scripted Find Examples

          • 2. Re: Button to perform Find against current user and name_first name_last
            RayGerman

                 I think I understand, and have found a script but am having trouble setting a variable to cache the account name for the find.

                 I created a new script and am using the edit script feature. I am at the second step Set Variable but I do not see a way to set  Substitute. All I can seem to create is Set Variable [$name; Value:( Get (AccountName))].

                 Any ideas?  I included the script and a screen shot of the script editor.

                  

                  

                 Set Error Capture [On]

                 Set Variable [ $name; Substitute (Get ( AccountName ) ) ]

                 Enter Find Mode []

                 Set Field [ < field you want to search> ; $name ]

                 Perform Find []

                 If [ Get (FoundCount) = 0 ]

                    Show Custom Dialog [ "Warning" ; "No Records Found" ]

                 End If

                 Set Error Capture [Off]

                  

                  
            • 3. Re: Button to perform Find against current user and name_first name_last
              philmodjunk

                   No need for any variable with this scripted method. And Substitute? why would you use that function here?

                   Enter find mode [] ---> clear the pause check box. It isn't cleared in your script example
                   Set Field [T17_Staff::Name_ ; Get ( accountName ) ]
                   Set Error Capture [on] --> should come BEFORE the perform find. It keeps the "no records found" dialog from interrupting your script if none are found.
                   Perform find[]

                   When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Do not click the specify button next to the repetition box. Click OK to close this dialog box. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.