AcumaticaZ
AcumaticaZ

Reputation: 13

How to stop adding new SOLines in Sales Orders Screen according to a condition in Acumatica

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

Answers (1)

Hugues Beauséjour
Hugues Beauséjour

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

Related Questions