Skip to main content
Solved

Interupting a process screen process with a web dialog.


martinxfe
Jr Varsity II
Forum|alt.badge.img

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?

 

Best answer by andriitkachenko

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
        }
    }
}

 

View original

darylbowman
Captain II
Forum|alt.badge.img+13

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.


andriitkachenko
Jr Varsity I
Forum|alt.badge.img+6

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
        }
    }
}

 


martinxfe
Jr Varsity II
Forum|alt.badge.img
  • Jr Varsity II
  • July 23, 2024

That was the missing ingredient. Thank you!


darylbowman
Captain II
Forum|alt.badge.img+13

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


andriitkachenko
Jr Varsity I
Forum|alt.badge.img+6
darylbowman wrote:

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


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings