CrossReference Lookup

I added some code to the OnAfterInput of No. on the sales order. If the item isn’t valid, it goes and looks at the cross reference table to see if it can find it there. That works great, but now I need to have it update the UOM depending on the barcode scanned.

So if I scan 0111 I want it to add 0123 with a UOM EACH

If I scan 0456 I want it to add 0123 with a UOM of CASE

Right now it is just adds it as an each. So I tried doing this but it barks about it being changed by another user. I’m sure it is because I’m trying to change the No. to the correct no. from the cross reference and update the UOM at the same time. So how could I have it update the no, and then change the UOM based on what I got back from the cross reference table. Thanks for you help.

IF (Type = Type:: Item) THEN BEGIN
CrossReferenceTable.SETFILTER(CrossReferenceTable.“Cross-Reference No.”, Text);
Text := CrossReferenceTable.“Item No.”;
“Unit of Measure” := CrossReferenceTable.“Unit of Measure”;

We changed the AltSearchField property of the “No.” field in the item table to the cross-ref.

And it does similar without code. Haven’t checked if it handles the sales uom as you want.

Have you tried Validating? Perhaps you need a modify…just off my head - havn’t tested

VALIDATE(“Unit of Measure”,CrossReferenceTable.“Unit of Measure”);