Solved

How to call WebDialogResult multiple times in a loop?

  • 20 September 2022
  • 3 replies
  • 179 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

3 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

Userlevel 1
Badge

I am on V2023R2.  My code is in SOOrderEntry_Extension.  I have a series of questions to ask and the WebDialogResult value of the first question is used on all subsequent questions.

 

I tried 

Base.Document.View.Answer = null;

Had same error as above WebDialogResult cannot be null

 

DuplicateFilter.View.Answer = WebDialogResult.None;

Error Message:  DuplicateFilter does not contain a value called View

 

Base.Document.View.Answer = WebDialogResult.None;

The code didn’t ask the next question.

 

Ask Question Code for 1st Question that works:

string message = $"Would you like to use your {roUnitsAvail} Roll Over Points? ";
if (Base.Document.Ask(message, MessageButtons.YesNo) == WebDialogResult.Yes)

 

 

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