Solved

How to call WebDialogResult multiple times in a loop?

  • 20 September 2022
  • 2 replies
  • 154 views

 

I call WebDialogResult multiple times in a loop.However, this window is displayed only once:(

My code:

foreach (DateTime dateTime in dateTimeList)
               {

                    WebDialogResult result = PaymentCalendar.Ask(ActionsMessages.Warning, PXMessages.LocalizeFormatNoPrefix(textMessage), MessageButtons.YesNo, MessageIcon.Warning, true);

                    if (result != WebDialogResult.Yes) continue;

                }

            }

 

Help me please

icon

Best answer by Dmitrii Naumov 20 September 2022, 15:39

View original

2 replies

Userlevel 7
Badge +5

It is related to the way Web Dialogs work in the framework. 

In fact, when you call a web dialog, it throws an exception and remembers the current method where the exception has been thrown from. It then sets ‘Dialog Answer’ variable to the view and executes the method again.

So, to make your code work, you’ll need to reset dialog answer in the PaymentCalendar view

 

foreach (DateTime dateTime in dateTimeList)
{
WebDialogResult result = PaymentCalendar.Ask(ActionsMessages.Warning,
PXMessages.LocalizeFormatNoPrefix(textMessage), MessageButtons.YesNo,
MessageIcon.Warning, true);

if (result != WebDialogResult.Yes)
{
PaymentCalendar.View.Answer = null;
continue;
}

}

 

It is related to the way Web Dialogs work in the framework. 

In fact, when you call a web dialog, it throws an exception and remembers the current method where the exception has been thrown from. It then sets ‘Dialog Answer’ variable to the view and executes the method again.

So, to make your code work, you’ll need to reset dialog answer in the PaymentCalendar view

 

foreach (DateTime dateTime in dateTimeList)
{
WebDialogResult result = PaymentCalendar.Ask(ActionsMessages.Warning,
PXMessages.LocalizeFormatNoPrefix(textMessage), MessageButtons.YesNo,
MessageIcon.Warning, true);

if (result != WebDialogResult.Yes)
{
PaymentCalendar.View.Answer = null;
continue;
}

}

 

It`s work

Thank you

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