March 23, 200520 yr 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?
March 23, 200520 yr Author 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.
March 23, 200520 yr 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) ] ...
March 24, 200520 yr Author [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. ...
March 24, 200520 yr 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'.
March 24, 200520 yr 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.
March 25, 200520 yr Author 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. Can You give me a link, please?
March 25, 200520 yr Here it is, right where I left it. http://www.fmforums.com/threads/showflat.php?Cat=0&Board=layouts&Number=137793 But listen to Ugo too. My basic demo would not handle sorting dates and numbers properly.
March 25, 200520 yr Author 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.
March 31, 200520 yr Author 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. Can You please, give some extra instruction for using Your faster loop solution? TIA dynamic_sort.zip
Create an account or sign in to comment