Hi All,
I want to stop adding new lines to a sales order based on a condition. How can I do this.?
I tried adding the following. But It did not worked.
protected void SOLine_RowInserting(PXCache cache, PXRowInsertingEventArgs e)
{
var row = (SOLine)e.Row;
if (row == null) return;
//Condition
if(Condition == true)
{
Base.Transaction.Delete(row);
}
}
Best answer by aaghaei
@charithalakshan49
Where this condition(s) are coming from? From header (SOOrder) or from line (SOLine) values itself?
If you want to prevent from insert based on header values the easiest option is
{
Base.Transaction.Cache.AllowInsert = false;
}
if you are playing with lines itself then you can use
{
e.Cancel = true;
return;
}
View original