Jump to content

Sort in a Script


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

Recommended Posts

Now this should be easy, but I can not figure out a work around.

Here is the simple problem, I need to have a simple script that sorts, BUT I do not want all fields from the table displayed.

If you do sort manually, you have the option of using only the current layouts fields, but this is not available in the script step.

Any ideas?

Link to comment
Share on other sites

A script that sorts is often referred to as a "hard-coded" script, in that the developer specifies the fields that are sorted in the Sort script step and turns off the Show Dialog. The user doesn't see any choices. Adding modularity to this type of script requires sending a parameter to the script, and using If ElseIF EndIF structure.

Can you expand on what you're trying to accomplish?

btw, here's a demo that I did a while ago that includes column headers in a list view that sort. Link

Link to comment
Share on other sites

normally I would prescript all my sort request. I have users that are requesting an easier way to sort. To ease the sorting, I wanted to make a script that limited the amount of available fields to sort by. I was going to make a layout with the available fields, script it to go to that layout, and sort.

The current table has 102 fields, and 98% are useless for my user group for sorting.

Also, I have a lot of the functions turned off with a custom menu, because of data security and to not confuse the user. Users prefer buttons.

Link to comment
Share on other sites

Well, you could have a list of "field names" (valuelist) by which to sort (attached to gSort). Then, using a script trigger attached to gSort, call a sort script that has the conditional structure I describe above.

Link to comment
Share on other sites

Thanks. Let me see if I understand, and expand on it a bit.

Lets say we have three field we want to sort by. I set up three global sort fields. Each global field is then tagged to a value list with fields that are the options to sort by.

We also have three calc fields that are equal to field data we are sorting by. This is dynamic. Change the global value, it will change the field value based on what you choose.

Then you hard code the script to sort by the first calc field, then the next calc, and then the last calc.

I like it......

Link to comment
Share on other sites

The current table has 102 fields, and 98% are useless for my user group for sorting.

Well, that would leave only 2.04 fields to sort by. :P

Anyway, even with 3 or more fields, it's not likely that all possible combinations will make sense when sorting. Usually there is only a relatively small number of useful sort orders - so your script can have multiple (hard-coded) Sort Records[] steps and choose between them according to the script parameter.

Link to comment
Share on other sites

I have it made up and it works great, but ran into another snag.

Some fields are numbers and some fields are text. In the calc filed if I specify number, it messes up the text, if I specify text, it messes up the number.

Any ideas....

Link to comment
Share on other sites

I figured it out. Instead of one calc field Dependant on the value list, I made two. One if for text and one for number. Only one of the two will be calculated. The sort then goes:

gSort1 (Text)

gSort1 (Number)

gSort2 (Text)

gSort2 (Number)

gSort3 (Text)

gSort3 (Number)

Hope this helps someone else later on down the road....

Link to comment
Share on other sites

This topic is 4390 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
 Share

×
×
  • Create New...

Important Information

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