RE: Like to insert line in custom table while creating new line in purchase order
First check whether the validateWrite method at table level is calling without clicking save button.
Refer to the below code - You need to validate the records before inserting into custom table.
PurchLine purchLine = sender as PurchLine;
PurchQtyTracking purchQtyTracking,purchQtyTrrackingValidate;
PurchParameters purchParameters;
purchParameters = PurchParameters::find();
if (purchParameters.QtyZeroPOLines == NoYes::Yes)
{
//add select statement to validate the record in custom table
select firstonly * from purchQtyTrackingValidate
where purchQtyTrackingValidate.RefRecId == purchLine.RecId;
if(!purchQtyTrackingValidate)
{
// to insert the current record only
ttsbegin;
purchQtyTracking.PurchId = purchLine.PurchId;
purchQtyTracking.ItemId = purchLine.ItemId;
purchQtyTracking.RefRecId = purchLine.RecId;
purchQtyTracking.doInsert();
ttscommit;
}
}
Thanks,
Girish S.