Wednesday, October 12, 2011

Entering Sales Orders by Barcode, GTIN, or any other reference

Dynamics AX insists that the ItemID be used on the Sales Line portion of the Sales Order Form. Many companies, though, have vendors that place orders by barcode number, industry identifier, or even vendor-specific ID. Here is a bit of code that lets the user enter any other number in the Sales Order Form (Form SalesTable) and have Dynamics look up the corresponding ItemID.

This example just does a lookup on the InventItemBarcode table, but it could easily be adapted to (also/instead) check any other tables, (InventItemGTIN, ExtCodeTable, CustVendExternalItem) in order to find items by their GTIN, industry code, or customer/vendor specific item number.

I implemented the code on the SalesTable form, but you could easily adapt it to just about any other form that requires an Item ID.

Hope this helps!





public boolean validate()
{

/*
Overridden validate method. If number entered does not match an ItemID
this will look up the entry in the barcode table and return
the first ItemID that is associated with that barcode.
*/

boolean ret;
ItemId ItemId;

InventTable InventTable;
InventItemBarcode InventItemBarcode;

;


ret = super();

ItemId = this.text();

If (ItemID != "" && !InventTable::exist(ItemId))
{
InventTable = InventTable::find(InventItemBarcode::findBarcode(this.text(), False, False).itemId);
if (InventTable.ItemId != '')
{
info(StrFmt("Barcode lookup. Using Item ID: %1.",inventtable.ItemId)); //Optional
SalesLine.ItemId = InventTable.ItemId; // sets the field correctly
this.text(InventTable.ItemId); // suppresses error 'item not found in relating table'
}

}

return ret;
}


4 comments:

srinu said...

Thanks this is what iam searching.
can you tell me how to get the inventdimid,and qty in the same menthod.

kaushik said...

Hello Reiff Lorenz,

Our company is planing to impliment the similar barcode functionality to our client.

Could you please provide me the exact model and brand details of the barcode scanner you have used to implement this functionality.

Regards,
kaushik

kaushik said...

Hello Reiff Lorenz,

Thanks for a great post.

Regards,
kaushik

Mark Jelic said...

Works great and so easy to fix what I think is a major ommission from the standard setup of AX!

As per comment from SRINU, would love for it to work with the QTY in that same Barcode Setup table to enter that automatically into Sales Order.

Thanks!