The CreatorCon Call for Content is officially open! Get started here.

ui action redirecting it to previous page

tghadage124
Tera Contributor
function onredirect(){
    g_form.setMandatory('u_close_code',true);
    g_form.setMandatory('u_percentage_complete',true);
    g_form.setMandatory('u_is_this_request_completed',true);
    action.setRedirectURL(current);
 
here I have set it to current but still its taking me to the previous page where I need to stay it on the same page. 
Please guide !!
8 REPLIES 8

Hi @tghadage124 ,

 

Tried in my PDI

it works seamlessly:

 

1)Also when your setting any fields to Madatory it will not back to previous page its form validation and you don't have set action.setRedirectURL(current);

2)And also "action.setRedirectURL(current)" its Server side method 

 

However it works.

 

UI Action:

HemanthM1_0-1724758233796.png

 

On the incident form:

I have used close code fied:

 

HemanthM1_1-1724758304490.png

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

Screenshot (344).pngScreenshot (345).png

still the same.

Hey @tghadage124 ,

 

Your fucntion call should be in onclick field not in the condition

 

if its not on the form bring it on

HemanthM1_0-1724777445529.png

 

 

 

 

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025

Ravi Gaurav
Giga Sage
Giga Sage

Hello @tghadage124 

This works in server side script of UI Action.

Please move this to server side script and validate.

 

 

 

RaviGaurav_0-1724766358821.png

 

--------------------------------------------------------------------------------------------------------------------------


If you found my response helpful, I would greatly appreciate it if you could mark it as "Accepted Solution" and "Helpful."
Your support not only benefits the community but also encourages me to continue assisting. Thank you so much!

Thanks and Regards
Ravi Gaurav | ServiceNow MVP 2025,2024 | ServiceNow Practice Lead | Solution Architect
CGI
M.Tech in Data Science & AI

 YouTube: https://www.youtube.com/@learnservicenowwithravi
 LinkedIn: https://www.linkedin.com/in/ravi-gaurav-a67542aa/