cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Using the GetSelection Sort option

mega-seagate
Contributor

Can someone help a Mega novice understand how to use the GetSelection Sort option?

 

I am trying to retrieve application objects, and then sort them by shortname.

 

'MegaContext(Fields,Types)
dim root as MegaRoot
set root = getRoot
for each app in root.GetSelection("Select Application", [shortname:A])
    print app.shortname
  cnt = cnt + 1
next
print "Count:" & cnt

 

This does not work as written, and I am unsure what the syntax is for adding the sort option (shortname:A)

 

Suggestions?

3 Replies

'MegaContext(Fields,Types)
dim root as MegaRoot
set root = getRoot
for each app in root.GetSelection("Select Application", -1, "short name")
    print app.shortname
  cnt = cnt + 1
next
print "Count:" & cnt

 

just put -1 in frotn of the sorting attribute.

 

regards

Is there a way to specify a descending sort?  In the documentation for GetCollection, it was mentioned that you could append A or D to the attribute name to have the sort be ascending or descending.  However "shortname:A" or "shortname:D" returns an error.

SVanSchoonlandt
Honored Contributor

'MegaContext(Fields,Types)
dim root as MegaRoot
set root = getRoot
for each app in root.GetSelection("Select Application", "short name")
    print app.shortname
  cnt = cnt + 1
next
print "Count:" & cnt

 

regards