Reputation: 13
I want to stop adding new lines to a sales order based on a condition in Acumatica. 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);
}
}
Upvotes: 0
Views: 42
Reputation: 8288
Set AllowInsert
cache property to false from the context of RowSelected
event.
void _(Events.RowSelected<SOLine> e, PXRowSelected baseMethod)
{
baseMethod(e.Cache, e.Args);
bool canInsertCondition = false;
Base.Transaction.Cache.AllowInsert = canInsertCondition;
}
Upvotes: 0