7 Replies Latest reply on Sep 21, 2014 8:42 AM by philmodjunk

    Sorting by 2 different sort parameters concurrently

    JohhnyHilly

      Title

      Sorting by 2 different sort parameters concurrently

      Post

      I am wanting to sort records based on 2 parameters in the following order but can't quite get it:

      1. By Property name; then
      2. on whether a bill has the status of Paid or Unpaid

      The script to show all bills for a single property works well, but my script for the Paid and Unpaid shows ALL bills (paid or unpaid) for all properties, not the one selected. What step do I need to put in here to take the bills from the property selected?

      Go to Layout [Bills (Bills)]
      Enter Find Mode[]
      Set Field [Bills::Status; "Paid"]
      Set Error Capture [On]
      Perform Find[]
      Sort Records

        • 1. Re: Sorting by 2 different sort parameters concurrently
          philmodjunk

          I think you mean "find" when you say "sort". (To "sort" means to arrange a set of records into a specified order.) Is that correct?

          You want to find all Paid or Unpaid records in Bill for a specific property. Right?

          There's no line in your script to specify criteria that will identify the property. You'll need a second set field step specifying the date for the "selected property". Exactly how that will work will depend on how you set up your layout so the user can select that property. This could be the current record on a property layout or a value selected in a global field formatted with a value list or some more sophisticated value selection tool....

          • 2. Re: Sorting by 2 different sort parameters concurrently
            JohhnyHilly

            Yes I meant find.

            And yes that is correct. I did as you suggested and added another Set Field step in the script where it takes the property ID from the global field that is selected to display the property. This works well but I now have one more question.

            If I have all records showing unsorted, what would I need to change to the script above to show all bills Paid/Unpaid for ALL properties. Is there a way in the same script to somehow exclude the Property ID global field when I want it for all properties?

            • 3. Re: Sorting by 2 different sort parameters concurrently
              philmodjunk

              IF the global property ID field is empty, doesn't it then find all properties with the specified "paid" or "unpaid" status?

              • 4. Re: Sorting by 2 different sort parameters concurrently
                JohhnyHilly

                No because a property is always selected in the dropdown menu, I am not sure of a way not to have one selected as the value list is based on the property ID.

                • 5. Re: Sorting by 2 different sort parameters concurrently
                  philmodjunk

                  The global field should start out empty. Just because you format it with a value list does not mean that it has to have a value. And you can add a button to clear it if you are using a value list format where it is not obvious to the user that you can put the focus in the field and clear it by pressing the back space. And your script can automatically clear this field after performing the find.

                  But a more important question is: If there's always a value in this field, what action on the part of the user is different when they want to see a list for all properties instead of just a selected property? We need to start from that context to either use a different script that does not specify the property ID in the find or pass a different script parameter to the same script that the script can use to determine whether or not to specify a property ID.

                  • 6. Re: Sorting by 2 different sort parameters concurrently
                    JohhnyHilly

                    I was hoping to avoid the user having to do another step, like a clear button, as they wouldn't know when (or why) to press it with the way I have it setup.

                    what action on the part of the user is different

                    I'm not sure to be honest. I was thinking for the value list of having another value "All" that could be selected for the find to show all properties, but if the values are based on the field PropertyID then that won't be possible. Worst case I could create a custom value list with property ID's and All, but I would like to avoid that if possible.

                    I am not sure how script parameters work sorry. I'm happy to start the script from scratch. I may have made it more confusing than it needs to be.

                    • 7. Re: Sorting by 2 different sort parameters concurrently
                      philmodjunk

                      My point here, is that FileMaker cannot read minds. There has to be some difference in your interface that you design into your system. It might be that you have a different button to click or it might be that this field is always empty until the user selects a value and then simply leaving the field empty produces the result that you need. It's your choice, but once you tell me that choice, we can then modify your script (if any modification is even needed) to work from that interface design.