You can say; “that won’t work”, and you are correct.  It will not work.

Some years ago I wrote a batch that loops through customer ledger entries and creates a total. Based on that total I wanted to create a claim and send it to the local bank for collection.  This batch has been working perfectly for many years but when I put this system to use for a client running the role tailored client this batch failed.

When I first looked at the batch looking for a different behaviour between the role tailored client and the classic client I saw nothing.  Decided that I would take a closer look next Monday.  When I woke up on Saturday morning and not really thinking about this the solution hit me.  There is a CurrReport.CREATETOTALS in the batch.  And that is ignored in the role tailored client.

So I changed the code. In OnPreDataItem trigger the code is now

[code]
IF ISSERVICETIER THEN BEGIN
TotalCustomerAmount := 0;
TotalCustomerEntries := 0;
END ELSE
CurrReport.CREATETOTALS(TotalCustomerAmount,TotalCustomerEntries);[/code]

and in the OnAfterGetRecord trigger the code is

[code]
IF ISSERVICETIER THEN BEGIN
TotalCustomerEntries := TotalCustomerEntries + 1;
TotalCustomerAmount := TotalCustomerAmount + "Remaining Amt. (LCY)";
END ELSE BEGIN
TotalCustomerEntries := 1;
TotalCustomerAmount := "Remaining Amt. (LCY)";
END;[/code]

I guess the lesson is; don’t use CurrReport.CREATETOTALS in your batches.

Leave a Reply

%d bloggers like this: