Error when opening Whse. Shipment page

Got following error after creating a Whse. shipment from a sales order in Nav 2017 when opening the Whse. Shipment from page “Whse. Shipment Lines”:

The record that you tried to open is not available. The page will close or show the next record.

The first strange thing is, the message is an info box, not an error message. After analysing the data in the sales order and tables Whse. Shipment Header and Whse. Shipment Line no error found. So what’s up? Also debugging did not really help, the debugger did not jump to the line, where the info box is created.

In the end i found out, that the reason for the strange behaviour was following: I created a new location for some tests, but forgot to add my user to the whse. employees, but that was not shown. The causal reason in the code: When opening page 7335 Whse. Shipment from page “Whse. Shipment Lines” following code is called in OnOpenPage trigger:

ErrorIfUserIsNotWhseEmployee() // from table 7320 Whse. Shipment HeaderIF USERID = '' THEN BEGIN  WhseEmployee.SETRANGE("User ID",USERID);  IF WhseEmployee.ISEMPTY THEN   ERROR(Text002,USERID);END;

Nice code, but what happens, if WhseEmployee.ISEMPTY is not empty? No error message is shown, but the info message from above with senseless text, which has nothing to do with the original error. Here it’s not checked, if there is a whse. employee created for the current user and the given location of the sales order. Thx microsoft.

What’s needed to correct the behaviour? Change above code to:

IF USERID = '' THEN BEGIN  WhseEmployee.SETRANGE("User ID",USERID);  WhseEmployee.SETRANGE("Location Code","Location Code");  IF WhseEmployee.ISEMPTY THENERROR(Text002,USERID);  END;

You should also change Text002 to “You must first set up user %1 as a warehouse employee for location %2.”.

cheers