2 Replies Latest reply on Apr 6, 2013 11:48 PM by jared944

    Search script: redirect to object if record count is >1

    jared944

      Title

      Search script: redirect to object if record count is >1

      Post

           Hello everyone,

           I am writing a search script that will identify records that have a certain ID, date, and match a keyfield. Mostly, this should only return one record unless a duplicate was saved.

           I want to write an IF statement that will redirect to an object (a filtered portal) if my seach returns more than one record.

           Any ideas?

            

           Thanks,

            

           Jared

        • 1. Re: Search script: redirect to object if record count is >1
          philmodjunk

               And where is that filtered portal? on the same layout or in a different layout?

               do you want to show it in a different window?

               Hidden inside a tab control?

               I routinely set up find scripts that check the number of records found that then switch layouts or pop up a window that lists the matching rcords in a list or table view. Clicking a row in this list then pops up the record in a form view. If only one record is found, the script takes you directly to the form view:

               The basic script outline:

               Enter FInd Mode [] ---> Clear the pause check box

               #Use one or more set field steps while still in find mode to specify the find criteria

               Set Error Capture [on] ---> keeps error dialog from interrupting the script if no records are found.
               Perform FInd [] --note there is no criteria specified in this script.
               Set Variable [$Found ; Value: Get ( FoundCount ) ]
               IF [ $Found = 1 // go straight to detail view ]
                   Go to Layout [ "Detail View" ( Sometable ) ]
               Else If [ $Found > 1 // go to form, window etc for listing all found records]
                  Go to Layout ["List View" (Sometable)]
               Else
                   Show Custom Dialog ["ERROR: No records were found " }
                   #Do whatever should be done if no records were found
               End If

               The step shown in blue is where you may need to use different steps if you want to pop up the list in a floating window or use Go To Object to reveal something hidden inside a tab control.

               For examples of scripts that find records using set field steps, see this thread: Scripted Find Examples

          • 2. Re: Search script: redirect to object if record count is >1
            jared944

                 This worked great!

                  

                  

                 Thanks!