UI Action not redirecting back to Change Record

Aaron Duncan
Mega Sage

I have a UI action as a replacement for the Implement button, as it performs additional checks. Everything works except the redirect. Instead of redirecting back to the Change Request, it goes to the list visited page. Can anyone see what I'm doing wrong?

 

//Initial function called. This is the Client-side 'onclick' function
function moveToImplement() {
    determineIfInWindow(); //Determine if the current DateTime is after the Planned StartDateTime.

}

//Function to Create the Modal
function showModal() {

    var early_reason = g_form.getValue('u_early_release_justification');
    var gm = new GlideModal("early_change_reason");
    gm.setTitle("Why are you releasing before the planned start date?");
    gm.setPreference("early_reason", early_reason);
    //start html that will be used in GlideModal
    gm.render();
}

//Function to determine if current date is passed the scheduled start date
function determineIfInWindow() {
    var date_number = getDateFromFormat(g_form.getValue('start_date'), g_user_date_time_format);
    var plannedStart = new Date(date_number);
    var nowDate = new Date();

    if (plannedStart < nowDate) {
        //If the planned date is smaller than now, then proceed.
        implementChange();
        return true;
    } else {
        //If it is in the future, then open the modal.
        showModal();
    }
}

//Function to actually implement the Change
function implementChange() {
    g_form.setValue("state", "-1");
    gsftSubmit(null, g_form.getFormElement(), "state_model_move_to_implement");
    current.update();
    action.setRedirectURL(current);
}

 The function implementChange is where it sets the state and then moves on to save and then redirect. 

1 ACCEPTED SOLUTION

Maik Skoddow
Tera Patron
Tera Patron

Remove the 

 current.update();

View solution in original post

2 REPLIES 2

Maik Skoddow
Tera Patron
Tera Patron

Remove the 

 current.update();

I removed it, and it still doesn't redirect back to the Change Request record.

//Function to actually implement the Change
function implementChange() {
    g_form.setValue("state", "-1");
    gsftSubmit(null, g_form.getFormElement(), "state_model_move_to_implement");
	action.setRedirectURL(current);
}