UI Action redirects me to wrong action

ronro2
Tera Contributor

Hello Guys! 

I have two different UI Actions, one called Defer: 

ronro2_0-1737044993464.pngronro2_1-1737045030797.png

The condition in Defer: 

- gs.hasRole('demand_manager') && (current.state == 2 || current.state == 3 || current.state == -4)

And one called Reject: 

ronro2_2-1737045100861.pngronro2_3-1737045155527.png


The condition in Reject:

- ((gs.hasRole('demand_manager')) && (current.state == 8 || current.state == -4 || current.state == 3 || current.state == 2 || current.state ==-15)) || (gs.hasRole('demand_user') && current.state == -15)

The problem: The Reject button (marked in red below) redirects me to state 10 instead of state 7. So the UI Action called Defer works as it should, while Reject is not. Do you know what I'm doing wrong? 

Thanks in advance.

2 ACCEPTED SOLUTIONS

Brian Lancaster
Tera Sage

Typically the state field is of type integer when it comes to the value. I'm surprised that the defer UI Action is working properly. You should be setting current.state = 7; instead of current.state = "7"; as the latter is converting it to a string instead of leaving it as an integer.

View solution in original post

Rejected is an OOB state, and the type mismatch—while a valid concern from a database perspective—is fairly common, and should still work as expected. In fact, the OOB Reject UI action has the following script:

 

 

current.state = '7';
current.update();
action.setRedirectURL(current);

 

 

@ronro2 - It's been a while since I worked with Demand states, but I recall there are some state management BRs that need to be fully understood. Have you checked the audit history to see if the state value is changing to 7, and then to 10, in separate updates? It might be helpful to share the full UI action.

View solution in original post

5 REPLIES 5

The solution was using different onclick-method names for the different buttons.