Hi Everyone,
I hope this message finds you well.
We are currently working on enhancing the functionality of the Appointment and Service Orders forms. As part of this improvement, we have implemented a notification feature that triggers based on specific conditions in the Service Order data whenever data is saved in either form.
While the functionality is working as intended, we have encountered an issue where notifications are displayed multiple times. This repetition is unintended and impacts the user experience.
Here is my code
public delegate void PersistDelegate();
[PXOverride]
public void MyPersist(PersistDelegate baseMethod)
{
var row = (FSAppointment)Base.AppointmentRecords.Current;
if (row == null) return;
bool flag = AppointmentNTE(row);
if (flag == false) return;
baseMethod();
}
public bool AppointmentNTE(FSAppointment row)
{
if (PYNTEIgnore.GetFlag() == true)
return true;
bool flag = false;
if (row == null) return false;
//FSAppointment appointment = Base.AppointmentRecords.Current;
//if (appointment == null) { return flag; }
FSServiceOrder serviceorders = SelectFrom<FSServiceOrder>.
Where<FSServiceOrder.refNbr.IsEqual<@P.AsString>>.
View.Select(Base, row.SORefNbr);
FSServiceOrderExt fSServiceExt = PXCache<FSServiceOrder>.GetExtension<FSServiceOrderExt>(serviceorders);
if (fSServiceExt.SSSNTEAction == "N" || fSServiceExt.SSSNTEValue >= row.CuryDocTotal || row.CuryDocTotal <= 0)
{
flag = true;
return flag;
}
if (fSServiceExt.SSSNTEAction == "W" && (fSServiceExt.SSSNTEValue > 0 && fSServiceExt.SSSNTEValue < row.CuryDocTotal))
{
// process or cancel Dialogue Box.
string msg = Messages.ServiceOrderWaringMsg;
WebDialogResult result = Base.AppointmentDetails.Ask(ActionsMessages.Warning, PXMessages.LocalizeFormatNoPrefix(msg), MessageButtons.OKCancel, MessageIcon.Information, true);
if (result == WebDialogResult.OK)
{
flag = true;
return flag;
}
else
{
throw new PXException(msg);
//return flag;
}
}
if (fSServiceExt.SSSNTEAction == "P" && (fSServiceExt.SSSNTEValue > 0 && fSServiceExt.SSSNTEValue < row.CuryDocTotal))
{
// Throwing Exception
string msg = Messages.ServiceOrderPreventgMsg;
//throw new PXException(msg);
WebDialogResult result = Base.AppointmentDetails.Ask(ActionsMessages.Warning, PXMessages.LocalizeFormatNoPrefix(msg), MessageButtons.OK, MessageIcon.Information, true);
//throw new PXException();
return flag;
}
if ((fSServiceExt.SSSNTEAction == "P" || fSServiceExt.SSSNTEAction == "W") && fSServiceExt.SSSNTEValue <= 0)
{
flag = true;
return flag;
}
return flag ? true : false;
}
Can you please suggested how fix this bug.
Thanks