Sales Order Lookup

I have noticed that in Sales Line table, if we add code to the OnLookup trigger of the field “No.” and then select an item from the lookup list the quantity from the previous line gets copied into the new line. This causes the Stock-Out screen to immediately open even before we leave the item# field. Is this a problem or is it supposed to work that way for some reason? Has anyone else noticed it? Pari Somasundaram

Hi Pari, That is because Navision uses the XRec at several places in the “Sales Lines” e.g. at the end of “No.” OnValidate:

VALIDATE(Quantity,xRec.Quantity);

You should clear the XRec, when you make a lookup by code, like this:

IF FORM.RUNMODAL(0, Item) = ACTION::LookupOK THEN BEGIN
  IF "Line No." <> xRec."Line No." THEN
    xRec.INIT;
  VALIDATE("No.", Item."No.");
END;

Reijer