Jump to content

Dynamic portal sort


Jalz

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

Recommended Posts

Hey all,

 

I have a portal which contains a sort based on a field called ItemName. I have used a custom sort order based on a value list called SortOrderA. The thing is, if a certain condition is met, I would like the field ItemName sorted by value list SortOrderB. Is this possible?

 

Thanks

Jalz

Link to comment
Share on other sites

Hide one or the other portals with Data > Behavior > Hide objects when.  You can stack the portals and hide the portal. Fields inside 'stick' with the portal and respect the hide as well.

  • Like 1
Link to comment
Share on other sites

  • 5 months later...
  • 1 year later...

Hello All, hoping to revive this old thread.

I have created a script that uses the idea presented on FMHacks (http://filemakerhacks.com/2011/04/07/portal-sorting-part-2/)

The idea behind the script is to create 2 sortfields, one of which will sort ascending and the other descending. A clever trick (using ScriptParameter) sets these fields to the contents of the various working fields in the portal. The script toggles asc to desc and vice versa so you can sort up and down with serial clicks. Set key to itself to redraw the portal

So here is the setup: fields "serial", "FN", "LN", "sortfield_asc", "sortfield_desc"

Portal sort order is by "sortfield_asc" ascending, "sortfield_desc" descending. Nothing else is in the sort order.

Script is triggered and it sets "sortfield_asc" to "LN",  "sortfield_desc" to "", and the portal gets sorted by LN in an ascending order. So far so good.

What should happen is that if the script is triggered again, then it sets "sortfield_asc" to "",  "sortfield_desc" to "LN", and the portal gets sorted by LN in an descending order.

But instead, this is what happens:

Script sets "sortfield_asc" to "",  "sortfield_desc" to "LN",  but the portal gets sorted by "serial" in an ascending order. "serial" is not part of any definition or sort order. I have the sort fields in the portal temporarily and I can see that they are set to what they are supposed to be set to but they are not sorted. 

For the life of me I can't figure out what is wrong here. Any suggestions, ideas would be most appreciated. 

These are the actual script steps:

#These 3 variables must be set up in this order:
Set Variable [ $sp; Value:Get ( ScriptParameter ) ]
Set Variable [ $$sortDirection; Value:If ($sp = $$fieldName and $$sortDirection = "asc"; "desc" ; "asc" ) ]
Set Variable [ $$fieldName; Value:$sp ]
#Setting the primary key to itself refreshes the portal contents Set Field [ practice::_Gkey; practice::_Gkey ]

This is what  the portal setup looks like:

0Untitled.tiff

Edited by Asu
Image did not show
Link to comment
Share on other sites

sorter_asc and sorter_desc are both defined as text fields. 

The funny thing is that one half of the script works as it should but the other is totally off the wall. Or rather, the script does what it is supposed to do but the portal sorts what it is NOT supposed to sort.

Link to comment
Share on other sites

This topic is 2712 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.