Tuesday, 2 December 2014

Get Barcode based on Dimension in AX 2012

public BarCodeString encodeBarcode(CustPackingSlipTrans _custPackingSlipTrans)
{
    BarcodeSetupId                      barcodeSetupId;
    BarcodeSetup                        barcodeSetup;
    Barcode                             barcode;
    ItemBarCode                         itemBarCode;

    barcodeSetupId  = InventParameters::find().BarcodeSetupIdPick;
    barcodeSetup    = BarcodeSetup::find(barcodeSetupId);
    barcode         = barcodeSetup.barcode();

    itemBarCode  =InventItemBarcode::findByProductDimensions(_custPackingSlipTrans.ItemId,
                            InventDim::find(_custPackingSlipTrans.InventDimId),
                                false,false,barcodeSetupId,false).itemBarCode;

    if (barcodeSetup.validateBarcode(itemBarCode))
    {
        barcode.string(true, itemBarCode);
        barcode.encode();
    }
    else
    {
        throw(error(strfmt("@SYS41409", barcode.barcodeType(), itemBarCode)));
    }

    return barcode.barcodeStr();
}

No comments:

Post a Comment

Calculate ledger balance by dimension set in X++ in AX2012/Dynamics 365 FO

There are a variety of ways users can view balances in the general ledger. Some of the most common options are: 1. Trial balance 2. Financia...