setRedirectURL(current) does not working when using with setAbortAction

Anh
Tera Contributor

I am modifying the Save button with the following logic:

  • If the Number field has a value greater than 100, update the record.
  • If the value is 100 or less, abort the action.

Here is the code:

 

action.setRedirectURL(current);

if (current.u_number > 100){

current.update()

} else {

current.setAbortAction(true);

}

 

 

The issue I'm encountering is that when setAbortAction is triggered, the setRedirectURL does not work as intended. Specifically, I am always redirected to the previous screen.

I have tried placing setRedirectURL(current) in various positions within the code (for example, between different lines), but nothing seems to resolve the issue.

How can I ensure that I stay on the current screen when the abort action is triggered?

2 REPLIES 2

Brad Bowman
Kilo Patron
Kilo Patron

It should work like this:

if (current.u_number > 100) {
    current.update()
} else {
    current.setAbortAction(true);
}
action.setRedirectURL(current);

Ayushi12
Mega Sage

Hi @Anh 
You can try something like below:

Ayushi12_0-1725970547070.png

If my response proves useful, please indicate its helpfulness by selecting "Accept as Solution" and " Helpful."

Thanks!