Skip to main content
Solved

How to call WebDialogResult multiple times in a loop?

  • Sep 20, 2022 11:17 AM UTC
  • 4 replies
  • 313 views
  • Translate All

Forum|alt.badge.img+2

 

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

}

 

View original

4 replies

Dmitrii Naumov
Community Manager
Forum|alt.badge.img+7
  • Community Manager
  • Answer
  • Sep 20, 2022 1:39 PM UTC

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

}

 

Translate

Forum|alt.badge.img+2
  • Author
  • Captain I
  • Sep 20, 2022 1:54 PM UTC

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

Translate

Forum|alt.badge.img
  • Jr Varsity III
  • Apr 19, 2024 8:20 PM UTC

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)

 

 

Translate

Forum|alt.badge.img
  • Jr Varsity III
  • May 1, 2024 1:20 PM UTC

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

 

Translate