Hi everyone,
I'm experiencing a strange behavior with a custom action in a processing screen (similar to Process Orders).
The Issue: When the process finishes, the "Processing" summary dialog appears correctly (showing 1 Success, 0 Errors, etc.). However, when the user clicks the "Close" button, the loading spinner appears briefly, and then the same success dialog pops up again. This creates an infinite loop where the only way to exit is to manually refresh the browser page.
Observations:
-
This happens even when the process is successful.
-
It occurs across multiple different custom actions I've developed.
-
I am using
PXLongOperation.StartOperationto handle the logic.
Code Snippet: Below is the logic for one of the actions causing this:
public PXAction<SOOrder> FRcreateTransfer;
[PXButton(CommitChanges = true), PXUIField(DisplayName = "Create Transfer", MapEnableRights = PXCacheRights.Select)]
public virtual IEnumerable frCreateTransfer(PXAdapter adapter, [PXDate] DateTime? shipDate, [PXInt] int? siteID, [PXDate] DateTime? endDate, [PXInt] int? usrFRLocationID)
=> ExecuteFRCreateTransfer(adapter, shipDate, siteID, endDate, usrFRLocationID, SOOperation.Issue, true);
private IEnumerable ExecuteFRCreateTransfer(PXAdapter adapter, DateTime? shipDate, int? siteID, DateTime? endDate, int? filterLocationID, string issue, bool v)
{
List<SOOrder> list = adapter.Get<SOOrder>().ToList();
// ... Filter logic ...
PXLongOperation.StartOperation(Base, delegate ()
{
bool anyfailed = false;
var orderEntry = PXGraph.CreateInstance<SOOrderEntry>();
for (int i = 0; i < list.Count; i++)
{
SOOrder order = list[i];
if (adapter.MassProcess) PXProcessing<SOOrder>.SetCurrentItem(order);
try
{
// ... Business Logic (Creating Transfer) ...
if (adapter.MassProcess) PXProcessing<SOOrder>.SetProcessed();
}
catch (Exception ex)
{
if (!adapter.MassProcess) throw;
PXProcessing<SOOrder>.SetError(ex);
anyfailed = true;
}
}
if (anyfailed)
throw new PXOperationCompletedWithErrorException(ErrorMessages.SeveralItemsFailed);
});
return list;
}
What I've tried: I suspect it might be related to how the IEnumerable returns the list or how the adapter state is being handled after the PXLongOperation starts.
Has anyone encountered this "Success Dialog Loop" before? Any advice on how to properly terminate the operation so the dialog closes permanently would be greatly appreciated.
Thanks in advance!