Solved

Usage of Dialog boxes

  • 2 November 2023
  • 2 replies
  • 137 views

Userlevel 3
Badge

Hi all,

I’m faced to a situation I have trouble implementing. If someone has an idea, it would be nice...

I have a graph (EAPInvoiceEntry) in which I have defined an action that has two purposes :

  • first, display a warning using a dialog box,
  • Then redirect to an other screen (graph EAPInvoiceProcess).

In the code below  I have used, the instructions after warning message calling are not invoked.

// EAPInvoice is a custom DAC, quite a clone of APInvoice       

public SelectFrom<EAPInvoice>
            .LeftJoin<Vendor>.On<Vendor.bAccountID.IsEqual<EAPRegister.vendorID>>
            .OrderBy<Asc<EAPInvoice.refNbr>>
            .View DocumentView;

        [ExcludeFromCodeCoverage]
        [PXProcessButton(Category ="Processing", DisplayOnMainToolbar =true)]
        [PXUIField(DisplayName = "Accept")]
        protected virtual IEnumerable acceptAction(PXAdapter adapter)
        {

            DocumentView.Ask("My title", "My Message", MessageButtons.OK, MessageIcon.Warning, true);

            // Instructions below are not called

            EAPInvoiceProcess eapInvoiceProcessGraph = CreateEAPInvoiceProcessGraph();
            throw new PXRedirectRequiredException(eapInvoiceProcessGraph.BaseGraph, false, "Redirection to AP50CG11");


            return adapter.Get();
        } 

        private static EAPInvoiceProcess CreateEAPInvoiceProcessGraph()
        {
            EAPInvoiceProcessBase baseGraph = PXGraph.CreateInstance<EAPInvoiceProcessBase>();
            return baseGraph.GetExtension<EAPInvoiceProcess>();
        }

icon

Best answer by Mike Gifford 3 November 2023, 19:50

View original

2 replies

Userlevel 4
Badge

I don’t see the PXAction declaration but assuming you have it in your complete code.  Also, have you stepped through/put breakpoints to ensure they aren’t ever being called or are you just not seeing the result you expect?

In my experience if this code were triggered from an event handler it would fail as you described or similar. However in an Action, I would expect it to work. Just wanted to confirm that it is being triggered from the Action being clicked rather than some other execution path.

Also, try capturing the result of the Ask and the code you want to execute within an if block - it should return and show you the value of the Ask.

The issue I believe is that in order to Ask - it is raising an exception and depending on the launch point - it doesn’t work the way you might expect due to the exception handling.

Here is a link to a similar situation/solution: https://stackoverflow.com/questions/52303443/insert-so-line-after-the-user-confirms-it-in-a-dialog-box

Userlevel 3
Badge

Hi @Mike Gifford ,

Your analysis is right : Ask method is raising an exception and the system execute a second time the calling method. This is what I didn’t caught. But my main error was not in the code I had posted here : I have created several tests. One is close from the code above, but with a slight difference : the Ask method was called into a PXLongOperation and this code doesn’t work.

        [PXUIField(DisplayName = "Accept")]
        protected virtual IEnumerable acceptAction(PXAdapter adapter)
        {

               PXLongOperation.StartOperation(graph, delegate ()
                {

                            DocumentView.Ask("My title", "My Message", MessageButtons.OK, MessageIcon.Warning, true);

            // Instructions below are not called

            EAPInvoiceProcess eapInvoiceProcessGraph = CreateEAPInvoiceProcessGraph();
            throw new PXRedirectRequiredException(eapInvoiceProcessGraph.BaseGraph, false, "Redirection to AP50CG11");

            }


            return adapter.Get();

 

The fact it uses different threads causes inconsistencies I think. I got confused between these two tests, the one I posted actually works asI could see later. Anyway, thanks for your help !

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved