Group break on Expression using script
I would like my group to break on an "expression" rather than directly on a data field. However my expression is complex and I'd like to use a script if possible rather the IIF statement.
As a simple test I've created a function in the "code" tab.
function GetCollatedGrouping: Variant;
begin
// This will become a complicated if-else function
// but for testing it is very simple
Result := <MyData."RecordNo">;
end;
However if I set the grouping to "Expression" and enter [GetCollatedGrouping], on previewing a "Invalid Variant Operation" error is given.
If I set the grouping back to being directly on the field and add a text MEMO to my form and enter [GetCollatedGrouping] as the expression, it correctly shows the RecordNo from the data set - so it seems FR can use this and I'm unsure why the grouping system can't.
So my question is, how can I use scripts within grouping expressions to be able to handle more complicated groupings and collation rules? (Please don't tell me to use IIF, I know this works but is insufficient for my needs).
Any advice would be appreciated.