Solved

action/method is not informed of restored deleted record by trigger

  • 20 April 2022
  • 3 replies
  • 73 views

Userlevel 7
Badge +8

I’m overriding on of Acumatica methods. This method is triggered when “Remove Hold” action is called. The method clears all records from Approval table. I would like to keep this records. So I have added a trigger on the table that restores any deleted record. My method is called after Remove Hold does it work. I would like to access the records restored by trigger and manipulate a certain record. What happens I can see the record exist in DB when I select from query analyzers but my method is not being informed and returns null value. How can I address this issue?

icon

Best answer by aaghaei 21 April 2022, 09:08

View original

3 replies

Userlevel 4
Badge +2

Based on what you’re describing, I might suggest some other ideas for options instead of using a database trigger:

  1.  Override the method, but change the part that deletes the records.
  2.  Override the method, but write the rows to a new custom table, and let the existing method remove them from the original table.  Then you can query the records from the new table, and even join to the existing table.
Userlevel 7
Badge +8

Thanks @tlanzer25.

I couldn’t override the method that resets the approval as it is one of the private protected methods buried deep down in one of the approval map classes.

instead, I removed the trigger, added a list variable to my method before calling Acumatica’s standard action, broke the link between approval table that will be rest and the current document by changing parent ref to a temp value, call Acumatica’s base method, and finally reestablishing the broken link by restoring from the list variable I kept in memory. To ensure either everything is completed as expected or fully rolled back, I put the full method in a transaction scope. This worked perfectly but was some extra work compared what could have been achieved using trigger.

Userlevel 4
Badge +2

@aaghaei , that sounds like a good way to get around it, and the transaction prevents commit to the database for the approvals.  I would of course want to test it fully to make sure not removing those approvals doesn’t affect any built in scenarios or workflows.

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved