Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

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

Recommended Posts

Posted

On one list layout, I have a 5 fields. It is possible created a just one script for sorting ascending/descending for all 5 fields?

Posted

I think that catch is in script parameter, but how to add a script parameter in sort step, when there isn't a calculation? In sort step You must specify a field for sorting.

Posted

Use a global for remembering the last sort, and a script parameter to know what the selected sort is on:


If [ Get(ScriptParameter) = "Name" ]

  If [ gLastSort = "Name Ascending" ]

    Sort [ Restore ; by Name (Decending) ]

    Set Field [ gLastSort ; "Name Decending" ]

  Else

    Sort [ Restore ; by Name (Ascending) ]

    Set Field [ gLastSort ; "Name Ascending" ]

  End If

Else If [ Get(ScriptParameter) = "Date" ]

  If [ gLastSort = "Date Ascending" ]

    Sort [ Restore ; by Date (Decending) ]

...

Posted

[color:"green"] Use a global for remembering the last sort

Yes, that is right.

[color:"green"]

If [ Get(ScriptParameter) = "Name" ]

  If [ gLastSort = "Name Ascending" ]

    Sort [ Restore ; by Name (Decending) ]

    Set Field [ gLastSort ; "Name Decending" ]

  Else

    Sort [ Restore ; by Name (Ascending) ]

    Set Field [ gLastSort ; "Name Ascending" ]

  End If

Else If [ Get(ScriptParameter) = "Date" ]

  If [ gLastSort = "Date Ascending" ]

    Sort [ Restore ; by Date (Decending) ]

...

[/color] 

That solution is OK for one layout. But my application contain almost 50 layouts, and will be very useful to create a dynamic system, one dynamic script for all possibly fields.

Something like.... that You shouldn't precise what field is sorting (e.g. "by Date")in script step:

Sort [ Restore ; by Date (Decending) ]

If can, on some way script parameter do that.... On that way created script can be useful in every future application. Dancing-Chilli.gif

...

Posted

In that case, look into doing it with GetField(). I posted a sample of this a couple months back. In was in a thread about 'dynamic reports' or 'dynamic portals'.

Posted

Hi,

Yes, GetField is the way to go as a start, but could get a bit more complex if the fields format could vary, from Time, Date, Number ot Text.

I've posted a demo in the Samples Forums to account for these cases.

The demo use a portal but can be used with lists as well.

Posted

In that case, look into doing it with GetField(). I posted a sample of this a couple months back. In was in a thread about 'dynamic reports' or 'dynamic portals'.

Sorry but I can't find your posted sample. frown.gif Can You give me a link, please?

Posted

Hi,

Yes, GetField is the way to go as a start, but could get a bit more complex if the fields format could vary, from Time, Date, Number ot Text.

I've posted a demo in the Samples Forums to account for these cases.

The demo use a portal but can be used with lists as well.

Thanx Ugo,

I'll get back later with my impressions. First I must read Your calc. field very patiently; it's complicated for my skill of filemaker. I hope that will help me.

Posted

Hi again,

Thanks everybody for help!

I attached my solution for dynamic sort here, and on post in Sample files too.

My solution required that every layout have a three extra fields ( text, number and date). They are a temporary fields in which values are copied from desired sort column fields.

Now, I have another question. Loop is very slow for thousands records; how can be faster? UGO sent a file RandomCreation few days ago, but unfortunately I can understand it. frown.gif Can You please, give some extra instruction for using Your faster loop solution?

TIA

dynamic_sort.zip

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