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