Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

save and redirect ui action

soukayna
Tera Contributor

hey i need to save my form then being redirected to another one. the problem i have that it shows a popin tellin that the information may be lost :

find_real_file.png

even if it save it correctly any ideas pls,

thanks

4 REPLIES 4

damodarreddyp
ServiceNow Employee
ServiceNow Employee

can you share the script written in UI action? it will be easy to validate the save and redirect


hi damodarreddyp,


sure , this is my ui action script :


find_real_file.png


you can do something like this... it should work:



Screen Shot 2017-08-01 at 9.10.15 PM.png




//Client-side 'onclick' function


function runClientCode(){


    //Call the UI Action and skip the 'onclick' function


    gsftSubmit(null, g_form.getFormElement(), 'redirect_page'); //MUST call the 'Action name' set in this UI Action


}




//Code that runs without 'onclick'


//Ensure call to server-side function with no browser errors


if(typeof window == 'undefined')


    runBusRuleCode();




//Server-side function


function runBusRuleCode(){


    // current.<field_name> = <value>;


    current.update();


    gs.addInfoMessage('You did it!');


    action.setRedirectURL('/problem_list.do');


}


hi damodarreddyp,


actually i m using an iframe and action.setRedirectURL() open the window in the middle of my page and it doesn't work well form me any other ideas ??


thanks