Hello All,
I have done action override a hundred times but I am facing an issue in Close Action of ServiceOrder that I am not sure why is happening. The problem is the "baseMethod" has a null value and as a result, I get an error that "An unhandled exception has occurred in the function 'MoveNext'. Please see the trace log for more details." Without this piece of customization, it is working just fine. Please note I have other stuff so that I am calling Base1 and Base2 in addition to the Base in my graph extension. Here is the part of the code relevant to the issue. Any help is appreciated.
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using PX.Common;
using PX.Data;
using PX.Objects.FS;
namespace Test
{
public class MyServiceOrderEntryExt : PXGraphExtension<ServiceOrderEntryWorkflow, ServiceOrderEntryVisibilityRestriction, ServiceOrderEntry>
{
public static bool IsActive() => true;
PXOverride]
public delegate IEnumerable CloseOrderDelegate(PXAdapter adapter);
PXUIField]
PXButton]
public virtual IEnumerable CloseOrder(PXAdapter adapter, CloseOrderDelegate baseMethod)
{
List<FSServiceOrder> list = adapter.Get<FSServiceOrder>().ToList();
// Do my validations on the list and determine the invalid items and add to invalidList
string invalidList = "List of invalid items";
if (!string.IsNullOrWhiteSpace(invalidList))
{
if (Base.ServiceOrderRecords.View.Ask("Warning ...", invalidList, MessageButtons.YesNo) == WebDialogResult.Yes)
{
return baseMethod?.Invoke(adapter);
}
}
return adapter.Get();
}
}
}