Skip to main content
Solved

RowPersisting event fired multiple times


Forum|alt.badge.img

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 

Best answer by Dmitrii Naumov

@NageswaraRaoAddanki60 The Acumatica Framework allows saving multiple records during save operation and it’s a frequently used practice to save a “parent document” while saving “child document”.

E.g. saving a Shipment changes a Sales Order status, thus during the Shipment save operation the related Sales Order is also saved. 

It’s intended behavior as well as the one you’ve described. 

View original
Did this topic help you find an answer to your question?

3 replies

Forum|alt.badge.img

You can try debugging the code to find where the duplicate notifications are thrown.

 

Help article on how to debug is below

https://help.acumatica.com/(W(18))/Help?ScreenId=ShowWiki&pageid=43396c5f-3cda-423f-b98d-e6d3c161f01b


Forum|alt.badge.img
varthinibhaskaran18 wrote:

You can try debugging the code to find where the duplicate notifications are thrown.

 

Help article on how to debug is below

https://help.acumatica.com/(W(18))/Help?ScreenId=ShowWiki&pageid=43396c5f-3cda-423f-b98d-e6d3c161f01b

Hi @varthinibhaskaran18 thank you for your response.

Yes, I know the debugging process.

Following the recent updates where we removed the notification functionality from the Appointment graph and retained it solely within the Service Order graph, we have encountered an unexpected behavior in the Appointment form.

the Appointment Form in our application. Specifically, it has been observed that when the 'Save' button is clicked on the Appointment Form, it inadvertently triggers the Service Order Graph event.

We believe this behavior may be unintended and could potentially impact the workflow efficiency. To ensure a smooth user experience and to avoid any unintended consequences, we kindly request your assistance in investigating and addressing this issue.

Please let us know if you require any additional information or if there are specific steps we should follow to facilitate the resolution process.


Dmitrii Naumov
Acumatica Moderator
Forum|alt.badge.img+7
  • Acumatica Moderator
  • 633 replies
  • Answer
  • September 3, 2024

@NageswaraRaoAddanki60 The Acumatica Framework allows saving multiple records during save operation and it’s a frequently used practice to save a “parent document” while saving “child document”.

E.g. saving a Shipment changes a Sales Order status, thus during the Shipment save operation the related Sales Order is also saved. 

It’s intended behavior as well as the one you’ve described. 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings