Hello Acumatica Community! I am running into an issue that I hope you can help with.
Users are creating service orders from opportunities. They are using project quotes. When the service order is created, I need to not include certain lines, for example, services. I tried finding a method to override when the service order is being created, but I was unsuccessful. So I tried using the RowInserting event and set e.Cancel = true. However, doing this gives me an error Object reference not set to an instance of the object. I can only assume that the CreateServiceOrder method is trying to update the row after I cancelled the insertion.
Then I tried using the RowUpdated event. When debugging, it appears that the row is removed from the cache (not put into the dirty queue, just removed). However, when the service order is finished creating, the row is still in the grid. I tried using RequestRefresh on the view, but to no avail. The gist of the code is below. Any help would be greatly appreciated, as always!
public bool _isCreating = false;
protected virtual void FSSODet_RowUpdated(PXCache cache, PXRowUpdatedEventArgs e)
{
var row = e.Row as FSSODet;
if (row == null) return;
if (row.LastModifiedByScreenID == "CR304000" && row.RefNbr.Contains("<NEW>"))
{
if (!_isCreating)
{
_isCreating = true;
InventoryItem item =
PXSelect<InventoryItem,
Where<InventoryItem.inventoryID,
Equal<Required<FSSODet.inventoryID>>>>
.SelectSingleBound(Base, new object[] { }, row.InventoryID);
var itemExt = item.GetExtension<InventoryItemExt>();
if (!(item?.StkItem ?? false))
{
cache.Delete(row);
//Base.ServiceOrderDetails.Delete(row);
Base.ServiceOrderDetails.Cache.RaiseRowDeleting(row);
Base.ServiceOrderDetails.Cache.RaiseRowDeleted(row);
Base.ServiceOrderDetails.View.RequestRefresh();
}
_isCreating = false;
}
}
}