UI Action redirect with alert

techies
Kilo Expert

Hi All,

I have a UI Action that redirects/refreshes itself like so,

        action.setRedirectURL(current);

I however wish to have an alert to the user g_form.addInfoMessage("here"); after the form has been refreshed. I can't do it before the redirect because the alert message just disappears once the page starts loading.

Is there anyway to alert the user and refresh the form?

Thanks for any help.

1 ACCEPTED SOLUTION

That is because you have that statement in the onClick function. onClick function runs on the client side, before the form is submitted. For the message to be displayed after the form reloads, you need to have that in the server function.



If all you are doing is redirecting, then there's no point in including Client functionality. Uncheck the Client checkbox and paste this code in the Script:



action.setRedirectURL(current);


gs.addInfoMessage('here');



But if you have some client code to be executed before the server code, then it should be something like this:



//Client-side 'onclick' function


function onClick(){


  // client side code goes here


 


  gsftSubmit(null, g_form.getFormElement(), 'unassign');


}




//Code that runs without 'onclick'


if(typeof window == 'undefined')


  serverCode();




function serverCode(){


      action.setRedirectURL(current);


      gs.addInfoMessage('here');


}


View solution in original post

6 REPLIES 6

Hi,



Can you post your entire script.


That is because you have that statement in the onClick function. onClick function runs on the client side, before the form is submitted. For the message to be displayed after the form reloads, you need to have that in the server function.



If all you are doing is redirecting, then there's no point in including Client functionality. Uncheck the Client checkbox and paste this code in the Script:



action.setRedirectURL(current);


gs.addInfoMessage('here');



But if you have some client code to be executed before the server code, then it should be something like this:



//Client-side 'onclick' function


function onClick(){


  // client side code goes here


 


  gsftSubmit(null, g_form.getFormElement(), 'unassign');


}




//Code that runs without 'onclick'


if(typeof window == 'undefined')


  serverCode();




function serverCode(){


      action.setRedirectURL(current);


      gs.addInfoMessage('here');


}