Saturday, June 25, 2005
Foxfire! Sort Orders: Hidden Data Items or Unselected
I was working on a Sort problem in build 397 and wanted to ensure this was written down as it's an interesting issue to deal with.
In Foxfire! 8.0, build 396, if you build a report that uses a sort order by an unselected data item, you'll get an error. The SQL being generated doesn't include the column and as a result, bombs out. This was the bug that I was trying to fix.
First some background:
When you do a sort in Foxfire!, you can choose to sort by three different choices:
a) a regular data item that you have included in your request (like Cars Make)
b) a calculated data item like Avg of Cars Mile
c) an unselected item (for example, if your report showed States and cities but was sorted by a State order column that went from West to East)
One of the ways to do the third option is to include that State Order column in your data items and simply hide it.
I personally prefer this option because it makes it OBVIOUS the way you are sorting the data. But Foxfire! has always let users also create sort orders on items that are NOT in the request's data items (referred to as Unselected).
Although the new object model now handles this scenario with some basic code:
loReq = loff.requests.additem("Detail")
loReq.DataItems.AddItem("Cars Make")
loReq.DataItems.AddItem("Cars Model")
loReq.Sorts.AddItem("Cars Mileage")
It may be useful to think about the internal arrays being used:
srt_ord( ) holds the sort order (A or D) but if the data item was not a selected data item, it would say "A[Unselected]"
If it WAS a valid data item, it would just say "A"
This also shows up in the Object model
loSort = loReq.Sorts.Items(1)
? loSort.Order && might say "A" or it might say "A[Unselected]"
Comment
In Foxfire! 8.0, build 396, if you build a report that uses a sort order by an unselected data item, you'll get an error. The SQL being generated doesn't include the column and as a result, bombs out. This was the bug that I was trying to fix.
First some background:
When you do a sort in Foxfire!, you can choose to sort by three different choices:
a) a regular data item that you have included in your request (like Cars Make)
b) a calculated data item like Avg of Cars Mile
c) an unselected item (for example, if your report showed States and cities but was sorted by a State order column that went from West to East)
One of the ways to do the third option is to include that State Order column in your data items and simply hide it.
I personally prefer this option because it makes it OBVIOUS the way you are sorting the data. But Foxfire! has always let users also create sort orders on items that are NOT in the request's data items (referred to as Unselected).
Although the new object model now handles this scenario with some basic code:
loReq = loff.requests.additem("Detail")
loReq.DataItems.AddItem("Cars Make")
loReq.DataItems.AddItem("Cars Model")
loReq.Sorts.AddItem("Cars Mileage")
It may be useful to think about the internal arrays being used:
srt_ord( ) holds the sort order (A or D) but if the data item was not a selected data item, it would say "A[Unselected]"
If it WAS a valid data item, it would just say "A"
This also shows up in the Object model
loSort = loReq.Sorts.Items(1)
? loSort.Order && might say "A" or it might say "A[Unselected]"
Comment