Jump to content
Server Maintenance This Week. ×

Need a tweak for portal sorting within a script


This topic is 983 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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

Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This topic is 983 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.