CurrReport.CREATETOTALS and the Role Tailored Client

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.

Customer warnings in sales

In the sales process NAV check for both credit limits and overdue balance on the customer. This is a needed process to inform the salesperson before posting the order or the invoice. However, the problem is that the warning is displayed every time the salesperson creates or modifies a sales line.

When a salesperson has agreed to sell this customer why should we continue to give him warnings that he has already approved?

I solved this by creating a new table to log warnings.  If a salesperson opts to continue the sales process despite the warning an entry is created in the log table.  Next time the system checks for a warning it will read the log table to see if a warning of that type has already been given to that salesperson.

The changes needed to implement this are minimal.

In Form and Page 343

  • move the local variable ExitValue from the ShowWarning function to Globals.
  • Add a code to the ShowWarning function to set ExitValue to zero before the warning logic.
  • Add a global function GetExitValue of type integer that will return the value of ExitValue

Then add functions to Codeunit 312 to check for log entry and to create a new log entry.

[code]
SalesHeaderCheck(SalesHeader : Record "Sales Header")
IF CustCheckCreditLimit.SalesHeaderShowWarning(SalesHeader) THEN BEGIN
//#01-
IF ExistsInWarningLog(
SalesHeader."Document Type",
SalesHeader."No.",
SalesHeader."Bill-to Customer No.",
CustCheckCreditLimit.GetExitValue) THEN EXIT;
//#01+
OK := CustCheckCreditLimit.RUNMODAL = ACTION::Yes;
//#01-
IF OK THEN BEGIN
AddToWarningLog(
SalesHeader."Document Type",
SalesHeader."No.",
SalesHeader."Bill-to Customer No.",
SalesHeader."Sell-to Customer No.",
SalesHeader."Posting Date",
CustCheckCreditLimit.GetExitValue);
CLEAR(CustCheckCreditLimit);
END ELSE
// IF NOT OK THEN
//#01+
ERROR(Text000);
END;[/code]
[code]

#01-()

ExistsInWarningLog(DocumentType : Option;DocumentNo : Code[20];BillToCustomerNo : Code[20];WarningType : Integer) : Boolean
WITH WarningLog DO BEGIN
SETCURRENTKEY("Document Type","No.","Bill-to Customer No.","Warning Type","User ID");
SETRANGE("Document Type",DocumentType);
SETRANGE("No.",DocumentNo);
SETRANGE("Bill-to Customer No.",BillToCustomerNo);
SETRANGE("Warning Type",WarningType);
SETRANGE("User ID",USERID);
EXIT(NOT ISEMPTY);
END;

AddToWarningLog(DocumentType : Option;DocumentNo : Code[20];BillToCustomerNo : Code[20];SellToCustomerNo : Code[20];PostingDate : Date;
WITH WarningLog DO BEGIN
INIT;
"Entry No." := 0;
"Date and Time" := CURRENTDATETIME;
"Bill-to Customer No." := BillToCustomerNo;
"Document Type" := DocumentType;
"Sell-to Customer No." := SellToCustomerNo;
"No." := DocumentNo;
"Warning Type" := WarningType;
"Posting Date" := PostingDate;
"User ID" := USERID;
INSERT;
END;

#01+()
[/code]

I created a new role with read permission to the warning table and assigned that role to administrative users. I added indirect read and indirect add to a general role that gives a sales person permission to create a sales invoice.

Warning Log Objects

[CurrLanguage :=] LANGUAGE([NewLanguage]) support in XMLPorts

It is commonly used option to change the reporting language according to a customer, vendor og an employee.  However, some reports are XML files.  I found that I also needed to change the data language in XML files.

The workaround is to change the GLOBALLANGUAGE before executing the xmlport.  To get similar language support in xmlports as in reports would be ideal.

Just created a suggestion on Microsoft Connect.  Go ahead and vote if you agree.