Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

UI Action updating twice

leslie8
Mega Expert

I have a custom table that is extended from Task.

I have a UI action that updates a custom field. It works fine if I press the button without changing anything else on the form. However, if I press the button after I've put some text into the WorkNotes field, the record updates twice in the activity log. The first update is the Approval State change and the Work Notes, and the second update contains the Approval State once again.

I have verified that no business rules are running against this table. Why is this happening? I need to ensure that the record is updated only once because I'm triggering notifications on the update.

approveIVT();

function approveIVT() {

  current.u_approval_state = 1;

  current.update();

  action.setRedirectURL(current);

}

1 ACCEPTED SOLUTION

Hi Leslie,



If you enable all debugging and perform the action where you have some text in the work notes, what are the outputs for when you limit to:



a.)   Business Rules


b.)   Logs


c.)   SQL



I am hoping that some information shows up in either of these logs that can shed some light on the situation.   I know you said you disabled BRs for the table however in my experience there can be BRs that run from other tables that can sometimes be missed (task, global, etc.).



There could be some BR for instance that is checking on the sys_journal field, that triggers an event when the work_notes change, which then triggers this duplicate update you are seeing.



Best regards,


Brian


View solution in original post

9 REPLIES 9

bcronrath
Kilo Guru

Hello Leslie,



What if you try putting the action.setRedirectURL(current) above the current.update()?


approveIVT();


function approveIVT() {


  current.u_approval_state = 1;


  action.setRedirectURL(current);


  current.update();


}



Best regards,


Brian


bernyalvarado
Mega Sage

Hi Leslie, some thoughts of things that you could try:



a) try to see if removing the action name Approve_IVT works. I believe you can leave that field blank if you're not relying on it somewhere else.


b) try pulling out the action.setRedirectURL(current); from the function and leaving it after the function call. Something like this:



approveIVT();


action.setRedirectURL(current);


function approveIVT() {


  current.u_approval_state = 1;


  current.update();


}



c) check if you have a client script that may be setting the value in an onChange or onSubmit


d) try removing the current.update() and see which effects it has.



I hope this is helpful! Blessings!



Thanks,


Berny


leslie8
Mega Expert

Hi guys, thanks for the suggestions. Unfortunately I have tried everything you mentioned and it still doesn't work.



*I have disabled ALL client scripts, UI policies, and business rules on the table



*When I remove current.update() the record does not update at all.



*When I remove action.setRedirectURL(current) it updates the record but still as a duplicate.



Note the duplicate update only happens when I do something else to the record at the same time, such as when I enter some text in the WorkNotes and then press the Approve button.



The activity log shows the WorkNotes updated once and the Approve updates twice.



Thank you


leslie8
Mega Expert

Hi guys,



I figured out that it is unrelated to the UI Action itself.



If I go into the form and manually change the ChoiceList from "Pending" to "Approved", enter some text into the WorkNotes and then Save, the duplicate update still happens.



So it is not the custom UI Action. There is something about the table or form that is causing this issue. Any idea? Thanks!