Another developer asked this question, but there was no answer to the question in terms of actually overriding the AddNew action on a grid.
When I click AddNew on the grid, I want to default a value in one of the grid fields based on a value in a filter. When you click AddNew, it adds a blank row. I don’t see any event that is being fired when you click that button. As such, I think the only thing I can do is to override the AddNew action and populate the value in the override.
As suggested in the above mentioned post, the suggestion is to use RowInserting. That event does not fire when you click the AddNew button. It fires when you leave the row.
This is a custom form, not an extension.
This is my code. In debug, the breakpoint on TEST is not hit.
[PXOverride]
public PXAction<ICSFSSScheduleLine> AddNew;
[PXUIField(DisplayName = "Add New", Enabled = true)]
[PXButton(DisplayOnMainToolbar = false)]
public void addNew()
{
var test = "TEST";
}
I tried to catch it in the FieldDefaulting event for the field, but that doesn’t get fired either.
protected void _(Events.FieldDefaulting<ICSFSSScheduleLine, ICSFSSScheduleLine.lower> e)
{
var test = "TEST";
}
The purpose for doing this is to prevent entry errors (PEBKAC).
Is this possible? Do I need to use a delegate? If so, I’m not able to find what the original code is I need to override.