Skip to main content
Solved

Interupting a process screen process with a web dialog.

  • 22 July 2024
  • 5 replies
  • 48 views

I have a process screen which applies prepayments to bills automatically based on matching invoice numbers. That much works great. 

I want to inject a step where the system checks for prepayments that remain open after their associated bill has already been closed out. I have the code that does this, and it works. 

What I can’t get to work is a user input prompt that says: “Unused prepayments have been found: Do you want to cancel or process bills anyways”

For the process to run efficiently, I don’t want the dialog to be raised per record, so I am avoiding events.

I’ve gotten the dialogs to work outside of events, but they seem to not cooperate with any form of long operation, including SetProcessDelegate(), which kind of undermines the whole thing. 

Does anyone know of a way around this?

 

5 replies

Badge +12

I'm not sure I have any great suggestions for how to accomplish what you want, but I can tell you why what you're trying to do isn't working. 

The processing screen is using a PXLongOperation to run the process. This is Acumatica's implementation of a background process or multi-threading. The processing is done on a separate thread from the UI thread. Once the process starts, there's no way to provide UI interaction until it's finished.

It's worth noting that you can have actions on a processing screen that are not executed as a background process, but the main process is always a background process.

Userlevel 6
Badge +2

You can ask for confirmation before the process starts using SetParametersDelegate:

using PX.Data;
using System.Collections.Generic;

namespace Sprinterra.Examples
{
public class URProcess : PXGraph<URRecord>
{
[PXVirtualDAC]
public PXFilter<URFilter> Filter;

[PXFilterable]
public PXFilteredProcessing<URRecord, URFilter> ProcessingView;

public URProcess()
{
ProcessingView.SetSelected<URRecord.selected>();
ProcessingView.SetParametersDelegate(AllowProcessing);
ProcessingView.SetProcessDelegate(list => Process(list));
}

public bool AllowProcessing(List<Record> records)
{
//You can filter when this check is invoked
if (Filter.Current.ActionID != Actions.ApplyPrepayment)
return true;

return ProcessingView.Ask(Constants.Title, Constants.Body, MessageButtons.YesNo).IsPositive();
}

public static void Process(List<URRecord> records)
{
// your processing logic
}
}
}

 

Userlevel 3
Badge

That was the missing ingredient. Thank you!

Badge +12

I’ve not seen this before. I’m curious about the presentation of this? Does this happen per-record?

Userlevel 6
Badge +2

I’ve not seen this before. I’m curious about the presentation of this? Does this happen per-record?

It is triggered as a validation before Processing starts. In the example above - the popup will appear. You can validate the result (.IsPositive()) - based on that, return true or false. If true - Processing starts, otherwise it is cancelled.

Reply