action.setRedirectURL(current) not working on UI Action

Zod
Giga Guru

HI,

while using an ui action I face to strage issues:

1. the   "action.setRedirectURL(current);" does not do its job - I always leave the form after the change is done ...

2. I'm using the   g_form.submit(); as this one woks - using   g_form.update(); also changes the value, but not actually saving it ...

function clickedReview() {

  g_form.setValue('ifieldname',value);

  g_form.submit();

  action.setRedirectURL(current);

}

Any Hint on this?

1 ACCEPTED SOLUTION

snehabinani26
Tera Guru

Hi Venffm,



This works in server side script of Ui Action.


Please move this to server side script and validate.




find_real_file.png


View solution in original post

5 REPLIES 5

snehabinani26
Tera Guru

Hi Venffm,



This works in server side script of Ui Action.


Please move this to server side script and validate.




find_real_file.png


Hi Sneha , 

will you be able to help me with this post i posted on community . 

 

https://community.servicenow.com/community?id=community_question&sys_id=61ea5c38dbdb7bc01cd8a345ca96...

Pradeep Sharma
ServiceNow Employee
ServiceNow Employee

Hello Vemffm,



Please refer below blog and adjust your code accordingly.


https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/



Let me know if you have any questions.


reginabautista
Kilo Sage

Hi vemffm



In addition to sneha's reply..



You need to use gsftSubmit for this purpose. Dont forget to add the Action name NOT the button name to the parameter.



SmartSelectImage_2017-05-04-07-21-40-1.png




function clickedReview() {


  g_form.setValue('ifieldname',value);


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


    gsftSubmit(null, g_form.getFormElement(), 'close_incident'); //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')


  Current.update();


  action.setRedirectURL(current);


}



More info here:


https://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/