3 Replies Latest reply on Oct 31, 2016 10:40 AM by philmodjunk

    Help with the script

    thong127

      Hello All,

       

      I have a button bars with a calculation to show the number of my expired materials I have the following below step scripts that attached to each to go to the related record, I don't know if my script is correct or the sequence is correct, my Refresh Object is not also working, because if the calculated result is 0, I clicked on it, still highlighted even there is a refresh object in my script.

       

      Set Error Capture [on]

      If [Get (ScriptParameter) = "Materials Expiring Today"

      Go to Related Record [Show only related records; From table: "Materials_Expiring Today" ; Using layout: "Materials" ( Materials)     

      If [Get (Foundcount) = 0]

      Show Custom Dialog ["No records" ; "No records where found."]

      End If

      Refresh Object [Object Name: "Materials Expiring Today"]

      End If

       

       

      Thank you.

       

      LOLA

        • 1. Re: Help with the script
          philmodjunk

          When you set up Go To Related Records (GTRR) and specify a specific layout. The script does not change layouts and no error message is displayed by your script if there are no related records to "go to".

          Thus, if there are no related records, you If step is checking the found set on your original layout--which is not going to have an empty found set  and thus it fails to detect the fact that there were no related records to go to.

          Instead, you need to either check for the existence of related records just before you use GTRR or check for an error code immediately after.

           

          Either:

           

          If [ Not IsEmpty ( RelatedTable::ForeingKey ]

            GTRR here

           

          or:

           

          GTRR

          If [ Get ( LastError ) = 0 // GTRR found related records]

          1 of 1 people found this helpful
          • 2. Re: Help with the script
            thong127

            Thanks Phil!

            • 3. Re: Help with the script
              philmodjunk

              This is an example of what I consider to be FileMaker's very substandard and inconsistent methods for handling script errors.

               

              For a full run down on what I think is wrong and what might be done to correct it, see this product idea:

               

              Better Script Error Handling