Insert Records in Item batch Table by code in Ax 2012

To Insert Records in Item batch Table by code in Ax 2012 you can take hints from below code. First, you need to check whether a record exists or not in the inventbatch table if it does not exist then you can insert records.

  if (InventBatch::exist(Itemid,Inventbatchid))  
     {  
     //error("Batchnumber already exists");  
     }  
     else  
     {  
       inventBatch.itemId=Itemid;  
       inventBatch.inventBatchId=Inventbatchid;  
       inventBatch.prodDate=mkDate(1,12,2017);//systemDateGet();  
       inventBatch.insert();  
     }  

No comments: