5 Replies Latest reply on Sep 18, 2014 10:42 AM by philmodjunk

    Displaying and Sorting records based on 3 considerations

    JohhnyHilly

      Title

      Displaying and Sorting records based on 3 considerations

      Post

      I am trying to do something rather simple but can't quite get it. I have a list of records (bills/invoices) that I would like to display and sort with 3 considerations.

      1. Show All Records, show Unpaid, show Paid
      2. Show only the records for certain Properties (i.e. show based on a field value from another table)
      3. Sort all the records no matter what is shown by date

      I'm having trouble with all of them as I am not sure how to write the scripts for each. Any assistance would be helpful.

      Thanks

        • 1. Re: Displaying and Sorting records based on 3 considerations
          philmodjunk

          Take a look at the scripted find examples found here: Scripted Find Examples

          Sort all the records no matter what is shown by date

          I don't know quite what you mean by that. To sort records means to arrange a group of records into a particular order such as sorting them in to descending order by the value in a particular field. Thus, "no matter what is shown by date" makes no sense.

          Caulkins Consulting, Home of Adventures In FileMaking

          • 2. Re: Displaying and Sorting records based on 3 considerations
            JohhnyHilly

            Sorry poorly worded. I just meant however the information is displayed whether it be displaying all records, or just unpaid records, I wanted each found set to be sorted by date. Anyway that, can be done in the script.

            Following your link, I can't seem to get the find to work. I am basing the find on the field Bill Status, if it is Paid or Unpaid. If I set it up as a global field, then create a field with dropdown as Paid or Unpaid it doesn't find anything. Trying something else, if I change the script so it's just for unpaid (see below) it says that no records match that criteria even though half of them have the status set to Unpaid. Not to sure why.
            Set Field [ Bills::Status; Bills::Status = "Unpaid" ]
             

            • 3. Re: Displaying and Sorting records based on 3 considerations
              philmodjunk

              You do not set up Bill Status as a global field. Global fields are what the USER uses to enter criteria while in browse mode before executing the script. You would use global fields only if user entered criteria is being used in your search.

              So you could set up a global text field, gstatus, with radio buttons for selecting "paid" or "unpaid"

              Your script would then be:
              Enter Find Mode[]
              Set Field [Invoices::Bill Status ; GlobalFIelds::gStatus ]
              Set Error Capture[on]
              perform find[]

              Invoices::BIll Status would be the field that you've always had with it's storage options unmodified. the blue field would have global storage specified and you'd put it on a layout where the user can select a value before performing this script.

              • 4. Re: Displaying and Sorting records based on 3 considerations
                JohhnyHilly

                Yes of course, makes complete sense. Thank you.

                As a visual thing, if I want to have 2 separate buttons, one for Paid and one for Unpaid, what would the script look like for each to display the respective records of Paid and Unpaid?

                Also, how would I conditionally format the button so when it has been pressed (and remains pressed) the background colour/shape changes for example? In the inspector, changing the format under "Pressed" doesn't do what I need as as soon as you remove your finger from the mouse/click, the formatting goes away.

                • 5. Re: Displaying and Sorting records based on 3 considerations
                  philmodjunk

                  It seems that your buttons will replicate the built in features of a radio button set. It might be simpler just to set up an OnObjectModify trigger on the radio button field.

                  But if you insist....

                  You can use the same script but specify "Paid" as the script parameter for one button and "unpaid" as the parameter for the other.

                  Set Field [ GlobalFields::gStatus ; Get ( ScriptParameter ) ]
                  Enter Find Mode[]
                  Set Field [Invoices::Bill Status ; GlobalFIelds::gStatus ]
                  Set Error Capture[on]
                  perform find[]

                  Then you can use GlobalFields::gStatus = "Paid" as the conditional format expression on the "Paid" button.