Showing posts with label In AX7 get Itembarcode through inventjouranltrans using OnValidatedWrite EventHandler. Show all posts
Showing posts with label In AX7 get Itembarcode through inventjouranltrans using OnValidatedWrite EventHandler. Show all posts

Friday, 13 April 2018

In AX7 get Itembarcode through inventjouranltrans using OnValidatedWrite EventHandler

class NEC_InventoryAdjustmentItemBarcodeEventHandler
{
 

    // //<summary>

    //// </summary>
    //// <param name="sender"></param>
    //// <param name="e"></param>
    [FormDataSourceEventHandler(formDataSourceStr(InventJournalLossProfit, InventJournalTrans), FormDataSourceEventType::ValidatedWrite)]
    public static void InventJournalTrans_OnValidatedWrite(FormDataSource sender, FormDataSourceEventArgs e)
    {

        FormDataSource                  inventJournalTrans_ds   = sender as  FormDataSource;
        InventJournalTrans              inventJournalTrans      = inventJournalTrans_ds.cursor();
        InventDim                       inventDim;
        InventItemBarcode               inventItemBarcode;
     
        inventDim           = InventDim::find(inventJournalTrans.InventDimId);
        inventItemBarcode   = InventItemBarcode::findByProductDimensions(inventJournalTrans.ItemId,inventDim,false,false);

        if (inventItemBarcode.RecId)
        {
            inventJournalTrans.NEC_itemBarCode = inventItemBarcode.ItemBarCode;
        }
    }

}