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

Adrian Ubeda
Mega Sage

Hi Mudit,

For debugging use 'alert' in the first function call, apart from this could you please try this code below?

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

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

function setRedirect(){
	current.setValue('state', current.u_previous_state);
	current.update();
	action.setRedirectURL(current);
}

If it was helpful, please give positive feedback.
Thanks,

If it was helpful, please give positive feedback! ✔
☆ Community Rising Star 22, 23 & 24 ☆

Hi,

I made the change but still no action on clicking the button. I added some alerts.

find_real_file.png

Out of these. Im only getting an alert for 'Im in moveToPrevious function'. 

No alert for previous value ot setRedirect

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

Hi,

g_form.getValue('u_previous_state') does give an alert! current.u_previous_state wasnt giving any.

I changed the script accordingly. On click of the button the page now reloads. 

However, the state change is not saved.

find_real_file.png

Before reloading, the state does change to scheduled, but this change isnt saved when i open the request again. Its back to Pending Customer State

My Script after Change is:

find_real_file.png

Switching gsftSubmit to g_form.save() as mentioned by @Anurag Tripathi works!