How can I link to UI page from another UI page?

jenny32
Tera Guru

Hi All,

        Please help me out !!

                                      In an "UI page",I have a button. Onclick/onsubmit of that ui page I need to map to another "UI page".

                                              I tried using anchor tag but it is not working.

                                                <a href="ui_page.do?name=render_chart"><button>Run</button></a>

                                              Tried client script also but not getting how can I write the functionality to map to another UI page.

Thanks in advance.

Jenny.

1 ACCEPTED SOLUTION

yetesh_ch
ServiceNow Employee
ServiceNow Employee

Hi Jenny,


Do this:



In first UI Page, write this:



<g:ui_form>


      <p>Click OK to run the processing script.</p>


      <g:dialog_buttons_ok_cancel ok="return true" />


  </g:ui_form>



In Processing Script of first UI Page, write this:



response.sendRedirect("ui_page.do?sys_id=<sys_id_of_second_ui_page>");



Copy sys_id of second UI Page and put it in <sys_id_of_second_ui_page>


View solution in original post

13 REPLIES 13

Anurag Tripathi
Mega Patron
Mega Patron

Hi Jenny,



I did something similar some time back. what i did was : there was a ui page getting rendered(popup, now a new window) and on a button click the current ui page was closed and another one was opened. let me know if you are looking for somehting similar.


-Anurag

jenny32
Tera Guru

Hi Anurag,



                      Ya. It's similar. Also may I know that can we display second ui page in the same page only when submit is clicked?


                  Your answer is valuable.



Thanks,


Jenny.


Hi Jenny,



Call any of these functions on your submit button as per your need




//Page2 is the name of the second ui page


//opens in the same page as a popup


function openSame()


{


  var dd = new GlideDialogWindow("Page2");


        dd.render();


}



//opens in a new tab and focuses the new tab


function openNew()


{


var url = new GlideURL('Page2.do');


var w = getTopWindow();


var newWindow = w.open(url.getURL(), "_blank");


newWindow.focus();


}


-Anurag

yetesh_ch
ServiceNow Employee
ServiceNow Employee

Hi Jenny,


Do this:



In first UI Page, write this:



<g:ui_form>


      <p>Click OK to run the processing script.</p>


      <g:dialog_buttons_ok_cancel ok="return true" />


  </g:ui_form>



In Processing Script of first UI Page, write this:



response.sendRedirect("ui_page.do?sys_id=<sys_id_of_second_ui_page>");



Copy sys_id of second UI Page and put it in <sys_id_of_second_ui_page>


Hi Yetesh,



                  I tried in the way you mentioned. The OK button is working fine but the cancel button is also redirecting to the "OK" button functionality that means both "OK and Cancel" button are working as same. When Cancel is clicked   I need it to be in same page. I tried with custom functionality in client script but that is not working or else I can have only "OK" button instead of OK and Cancel. Is there any other glide functionality available for it?   Guide me what can we do for this.


                  Also do anyone have idea how can we display different ui pages in single ui page only on "submit/OK" button is clicked.



Thank you