I am now trying to find out how to rearrange the order in a portal or report. It would be nice to be able to drag the orders up or down in the portal to rearrange them however the user feels they need to be arranged.
I assume you have sorted the portal by various fields and but cannot get the desired result. If so, you can always define a field, maybe called "Order" (number result) in your line items table. Place the field in the portal and let the user enter the numbers, then click outside the portal. If the portal is sorted by Order (ascending) the line items will appear in the order the user desired . Of course, this works best if you don't have too many portal rows being displayed.
Check out the info on this blog: several demos & articles could help out the fmp7 files convert to 12 nicely.
Remember portals, relationships and records can be sorted to maintain continuity across portals and reports.
To do this you have to pre-define their sort options - all of the fields that the portal can be sorted on. Then create a global field in the header record that has a value list of the options. For example, "Inv#, Date, Amount..."
Then in the portal records create a calc field that references the global and returns the appropriate data. For example, Case([Header::Global] = "Inv#", Invoice Number Field, [Header::Global] = "Date", Date Field... and so forth.
Then sort the portal on this calc field. There are several gotchas (one big one):
-It's an unstored calc and therefore potentially too slow. For less than 100 records you are probably OK. Make sure the data driving the calc in the portal records is local to the portal table. If it has to resolve across relationships the speed hit will be dramatic.
-You should have the calc field return a default value to sort the portal before they make their choice.
-The big gotcha is data type. The sort field probably needs to return a Text type, which will make numbers sort incorrectly (1, 10 11, 12, 2, 21). You need to turn numbers into text strings. This is usually done by "padding" it with zeros. For example: right("00000000" & Number Field, 8) will return for 1 = 00000001, 10 = 00000010, 2 = 00000002, forcing the numbers to sort as expected.
Note that dates are actually number values and can be treated like numbers with the function: GetAsNumber(Date Field).
Post back if you get stuck.
Here is another idea for portal sorting only. If you have users that want to see portals sorted differently, you could Insert > Tab Control. Make one tab for each sortable field in the portal. Place the same portal on each tab, taking care to align them all identically. Then sort each portal differently. For example, name one tab "Date" and sort the portal on that tab by Date; name one portal In# and sort the portal on that tab by Inv#, etc., etc. This is a one time set up with no "gotchas" and allows each user to select the tab they want.
In another discussion on this subject a few weeks back, one idea was to assign a sorting order field to the portal records, and then add Up-arrow and Down-arrow buttons in each row. Those arrow buttons would swap out the order number of the record above or below with the button record to cause them to reorder with a simple click of the buttons.
The portal is sorted on that number field, and that field is populated with a creation-order or consecutive serial number at creation. [Older records which lack the number could be populated using replace field contents when unsorted (creation order) by Get(RecordNumber).]
In my opinion, that was the simplest suggestion offered for allowing users to reorder portal records with up/down buttons.
Retrieving data ...