Skip to main content
Answer

How to call WebDialogResult multiple times in a loop?

  • September 20, 2022
  • 4 replies
  • 271 views

Forum|alt.badge.img+1

 

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

Best answer by Dmitrii Naumov

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

}

 

4 replies

Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • Answer
  • September 20, 2022

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

}

 


Forum|alt.badge.img+1
  • Author
  • Semi-Pro III
  • September 20, 2022

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


Forum|alt.badge.img
  • Jr Varsity III
  • April 19, 2024

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)

 

 


Forum|alt.badge.img
  • Jr Varsity III
  • May 1, 2024

I ended up creating a smart panel and consolidated 4 messages into one screen.  The following video was excellent at showing how to create a smart panel.  It was a lot quicker than I thought it would be.

https://www.youtube.com/watch?v=Knp723AFQII&t=1166s