UI Action Script Not working - State Change

Mudit4
Kilo Expert

Hi,

My Use Case is: 

I have a field (u_previous_state) which is stores a String type value. It stores the value of the previous state.

I want to have a button, a UI Action which will change the state of my change request back to the previous state.

Here are the screenshots for the same:

find_real_file.png

Here -2 is the state value of previous state ('Scheduled' in this case)

My Script is as follows:

find_real_file.pngCondition- Current state is 'Pending Customer'-> value '-50'

The template is similar to some UI Actions built in in my developer instance.

However, when i click the ui action button, nothing happens. Is there something wrong with this script? 

1 ACCEPTED SOLUTION

Replace current.u_previous_state with g_form.getValue('state'); for line 3

For line 11 replace alert() with g_form.addInfoMessage('setRedirect function')l

View solution in original post

11 REPLIES 11

Could you please try this and say which values is returned in alert?

function moveToPrevious(){
	alert('previousValue: ' + g_form.getValue('u_previous_value'));
	gsftSubmit(null, g_form.getFormElement(), 'state_model_move_to_previous');
}

if (typeof window == 'undefined')
	setRedirect();

function setRedirect(){
	current.setValue('state', g_form.getValue('u_previous_state'));
	current.update();
	action.setRedirectURL(current);
}
If it was helpful, please give positive feedback! ✔
☆ Community Rising Star 22, 23 & 24 ☆

Hi,

Yes it returns '-2' in the alert. 

Setting the value in moveToPrevious function and using g_form.save() works!