3 Replies Latest reply on Jun 20, 2012 9:33 AM by philmodjunk

    Scripting question with Go to Related Records.

    SteveMartino

      Title

      Scripting question with Go to Related Records.

      Post

      Hello all....again. Making progress thanks to the help of this forum...specifically Phil :)

      Here's the question/problem.

      1.  On my customer layout, I would like to go to Related Records of Deliveries. So of course I made a button.  If there are no related records, nothing happens (as predicted).  I would like the button to run a script, when I click it, it goes to Related Records of Deliveries, if no records, it goes to the Deliveries Layout, and opens a new record, and drops the customer name in the first field.  As a beginner, I've tried writing this scipt (many ways), with the help menu and books in hand, but have had no luck.

      2.  I was also wondering, if on the button to go to related records, on the customer layout, if it was possible to merge a field onto it that would show a count of related records?

      Any suggestions would be fantastic.

      Thanks again.....and again

      Steve

       

        • 1. Re: Scripting question with Go to Related Records.
          philmodjunk

          I am assuming this relationship here:

          Customer::CustomerID = Deliveries::CustomerID

          1) There are several ways that you can detect whether or not any related records exist:

          Option A:

          IF [ IsEmpty ( Deliveries::CustomerID ) //any field in Deliveries that is never empty will work ]

             # put script to go to deliveries layout and create a new record here. Copy the current customer ID into a variable before changing layouts so your script can put this value into the appropriate field in the new deliveries record to link it to your current customer record.

          Else

             PUt Go to Related Records here

          End If

          Option B:

           Go to Related Records
          If [Get ( Lasterror ) // GTRR Failed ]
             # Put same script described for no related records in OPtion A here.
          End If

          2) Yes you can. You can use a calculation field with: Count (Deliveries::CustomerID) as the merge field. If you have FileMaker 11 or newer, you can also put a variable as merge text on top of your button and use a conditional format expression to assign the record count to the variable.

          You can also use a conditional format to change the color of the button to show whether or not any related records exist and a tool tip can be defined that uses the count calculation to put up a different tool tip message depending on whether or not any related delivery records exist.

          • 2. Re: Scripting question with Go to Related Records.
            SteveMartino

            Thanks Phil, looks like thats the solution.  Also looks like I cant decipher it.....lol.....   But I will try, and try, and try.

            As always, thanks for your help.  I shouldve just hired you from the get go.  Or just send a check.

            BTW, I'm not sure of the rules, so I'll ask generically.. Is someone who posts, allowed to contact a member, who may or may not have their own business, to hire them for a project? 

            • 3. Re: Scripting question with Go to Related Records.
              philmodjunk

              For such contacts, you can click their forum name or avatar graphic an send them a private message.