August 17, 20214 yr Howdy, howdy: I found a neat way of performing a sort within a portal (in the attached file), but I'm stuck trying to amend one of its scripts' steps: in the setPortal_refresh [field] script, line 7, it has: ExecuteSQL( "SELECT ID from Contacts WHERE State = ? ORDER BY " & $field & Case ( $$sort_desc; " DESC" ); ""; ""; States::abbreviation ) The thing is, I want to exclude referencing a state--I just want to be able to sort each column's contents, state notwithstanding. I tried removing the WHERE part of the code but I'm just not getting the syntax right. How would I tweak the syntax to accomplish my goal...or by tweaking the syntax it would cause the portal sort script to fail? As always, TIA for your help. Cheers, Rich Portal_sort_fast12.fmp12.zip
August 17, 20214 yr If I am not mistaken, the syntax would be: ExecuteSQL( "SELECT ID from Contacts ORDER BY " & $field & Case ( $$sort_desc; " DESC" ) ; ""; "") I am not sure why you would want to exclude the WHERE clause, though. Its purpose is to reduce the selection to the records shown in the portal. If you remove it, you will be sorting all records in the Contacts table and present the sorting field calculation with a much larger list. I don't think it will affect the final result*, but it will add unnecessary complexity to the process. -- (*) Caveat: I only glanced at the file and I could well be missing some finer point.
August 18, 20214 yr Author Thanks again, and that's a good point about sorting through all the records in table; I'll have to re-evaluate the solution before I put my foot in it.
Create an account or sign in to comment