CHAPTER 02: Portal Sorting
So I came across a client database that had a rather odd way of sorting a portal. The portal was located in a products table and was designed to show sales history. The columns in the portal were order id, date, company, quantity and order status. The portal had buttons to sort the row by date, company and qty. The customer wanted to add the ability to sort by order status.
The default sort for the portal was by the sales order date and the company on the sales order. The buttons on the three sort options were all tied to Go To Object script steps. This was very odd to me and I needed to research this technique. The buttons themselves were broken down into ...
DATE COLUMN BUTTON
Let( $$date = Choose( $$date; 1; 0);
Choose( $$date; "Date"; "Date D")
COMPANY COLUMN BUTTON
Let( $$company = Choose( $$company; 1; 0);
Choose( $$company; "Company"; "Company D")
QTY COLUMN BUTTON
Let( $$qty = Choose( $$qty; 1; 0);
Choose( $$qty; "Total"; "Total D")
Looking at the sort fields themselves, nothing remarkable. The company field was a placebo calculation field that was equal to related company name on the sales order. The date field was a lookup field from the sales order. I didn't see any hidden tabs but I thought I'd investigate. Sure enough, the darn thing is a layered hidden tab configuration. The tab have the same portal but with a different default sort order and the sort buttons do not sort but simply go to the correct tab with the corresponding default sort order portal.
This required me to take a closer look at the calculations that drive the Go To Object and I'm certainly glad I did. What the developer is doing is doing is toggling between an ascending sort for the portal and a descending sort. I don't use the Let or Choose function that often and this is a marvelous way to use them. So I went ahead and deconstructed the tabs and add a couple tabs of my own for the status sort. One tab to hold the portal for the ascending sort and one for the descending sort.
Needed to add a placebo order status field in the sales order line item table. This is because the portal is linked to the sales order line items and the status is linked to the order itself. I added my own sort button for status and attached my revised version of the Go To Object step ...
Let( $$status = Choose( $$status; 1; 0);
Choose( $$status; "Status"; "Status D")
I then wired everything back up and it worked like a charm!
More info about the author and FileMaker in general, contact me at email@example.com.
© 2009 - Dwayne Wright - dwaynewright.com
The material on this document is offered AS IS. There is NO REPRESENTATION OR WARRANTY, expressed or implied, nor does any other contributor to this document. WARRANTIES OF MERCHANT ABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY DISCLAIMED. Consequential and incidental damages are expressly excluded. FileMaker Pro is the registered trademark of FileMaker Inc.
Help support this blog by considering a donating to its ongoing growth. For more details, please visit http://www.dwaynewright.com/donate.html