UI page processing script

Pavan Dev
Tera Contributor

Version: Madrid

Scoped Application

Hi all,

I am facing an issue to redirect the URL back to the form from the UI page. I have a UI page that displays pop up with some fields. After the user successfully submits the pop up with the information user clicks Ok. On the 'OK' button click, it should redirect back to the screen that brought up the pop-up instead it is redirecting to the new UI page form. Below is the code I used:

<g:dialog_buttons_ok_cancel ok = "return true" cancel = "return continueCancel()"/>

To redirect back used the below standard code in the UI processing script:

var urlOnStack = GlideSession.get().getStack().bottom();
response.sendRedirect(urlOnStack);

 

Any help what might be the issue?

Thanks in advance,

Pavan.

 

1 ACCEPTED SOLUTION

Allen Andreas
Administrator
Administrator

Hi,

What I do is add this hidden input type to the HTML section:

<input type="hidden" id="system_id" name="system_id" value="${sysparm_record_id}"/>

Then, in your processing script you can do something like (EXAMPLE):

var url = 'incident.do?sys_id=' + system_id;
response.sendRedirect(url);

Just replace incident with the name of your table and it will redirect back to the original record.

Please mark reply as Helpful/Correct, if applicable. Thanks!

 


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

View solution in original post

8 REPLIES 8

Hi,

Please try again and ensure there isn't any other conflicting code here.

Make sure you add the hidden line to the HTML section of your UI Page and then in the processing script, you use only those 2 lines I gave for supplying the URL and the redirect. Don't use any prior code you had.

This will take the record id, which was pulled from the URL for the record, which still exists even when calling a UI Page, and then using that to pass it back over to the redirect to send the user back to the page when they are done.

I'm not sure what you mean by it's redirecting them to "the new record".

Please mark reply as Helpful/Correct, if applicable. Thanks!


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

This did the trick for me! Thanks!

You are very welcome and thank you for leaving a comment letting us all know it helped! 😁


Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

emir
ServiceNow Employee
ServiceNow Employee

do you have multiple browser sessions open? Can you try this with just one browser tab open?