The Zurich release has arrived! Interested in new features and functionalities? Click here for more

How to cancel previous ui page after clicking ui action

Debarpita Basak
Giga Contributor

Hi All,

I want to cancel previous ui page after click ui action button it will reload fresh ui page and will cancel the other page which is loaded

full scenerio:

Please Help me i click one ui button(Send_deb) it will display 1st ui page then in first ui page if i click one button it will call the 2nd ui page then in 2nd ui page if i click one button(Deb) it will call the the same ui button which display the 1st page but cancel previous displayed 1st page and 2nd page . @ankurbiswas 

 

10 REPLIES 10

Hi Anirudh,

I tried both the solution but it is not working as per my requirement. Kindly help me

 

Please check response from AnirudhKumar and share us the updates

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Hi ankur,

Hi Anirudh,

Please Help me i click one ui button(Send_deb) it will display 1st ui page then in first ui page if i click one button(2nd page) it will call the 2nd ui page then in 2nd ui page if i click one button(Submit) it will click the the same ui button(Send_deb) again which display the 1st page but cancel previous displayed 1st page and 2nd page that means i am calling the ui action twice and second time when i am calling ui action Send_deb It will call and display the first page

Code for Ui action Send_deb :

 
 
 
 
 
 
 
 

 

 

 

 

 

script :

function clicksend() {

var dialog = new GlideDialogWindow("sch");
dialog.setTitle("1st_page");
//dialog.removeCloseDecoration();//ruchi.g.kumari_121142020 : added to remove x icon from top right corner of the ui page
dialog.setSize(750, 300);
dialog.render();
}
gs.addInfoMessage("Test_Send_email_by_Deb");

 

1st ui page:

html part:

<form>
<div>
<label for="site-search">Search the word:</label>
<input type="search" id="mySearch" name="q"
placeholder="Search the site..." size="30"/>
<button type="button" onclick="searches()">Search</button>
<button type="button" onclick="ruchi()">2nd page</button>
<button type="button" onclick="cancel()">Cancel</button>
</div>
</form>

client script part:

function searches(){

var short_text = g_form.getValue('mySearch');
var sita = g_form.getValue('short_description');

var ram = sita.search(short_text) > -1;

var regExp = new RegExp(short_text, "gi");
var x = (sita.match(regExp) || []).length;

var s1=sita.toString();
var regExp = new RegExp(short_text, "gi");
var s2 = s1.replace(regExp,'*');
alert("All replaced. The count "+ ' '+(x));
g_form.setValue("short_description",s2);;

GlideDialogWindow.get().destroy();
return false;

}


function ruchi(){
var dialog = new GlideDialogWindow('search');
dialog.setTitle("2nd");
dialog.setWidth(400,230);
dialog.render();

}

function cancel(){
//Close the dialog window
GlideDialogWindow.get().destroy();
return false;
}

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

2nd ui page:

html part:

<form>
<div>


<label for="site-search"><h2>Search the word :<span style ="padding-left:10px;"></span></h2></label>
<input id="mySearch"
placeholder="Search the word..." size="50" />

<g:evaluate var="jvar_num"

expression="RP.getWindowProperties().get('num')" />

<h4><button type="button" onclick="searchReplace()">Search</button>

<button type="button" onclick="deb()">submit</button>


<button type="button" onclick="cancel()">Cancel</button></h4>



</div>
</form>

 

client script part:

function searchReplace()
{
var stext = g_form.getValue('mySearch');
var numb = g_form.getValue('number');
alert("Number " + (numb));
alert("Text " + (stext));
var ga = new GlideAjax('ParentChildSync');
ga.addParam('sysparm_name','scrubText');
ga.addParam('sysparm_number',numb);
ga.addParam('sysparm_stext',stext);
ga.getXML(callback);


}

function callback(response) {

var answer = response.responseXML.documentElement.getAttribute("updcount");
alert("Replaced count " + (answer));
GlideDialogWindow.get().destroy();
return false;

}

function cancel(){
//Close the dialog window
GlideDialogWindow.get().destroy();
//return false;
}


function deb(){
gsftSubmit(null, g_form.getFormElement(), 'click_send');// it will click ui action Send_deb button
}

 

Last part remaining to complete : by clicking submit button it will click the ui action button Send_deb and load the 1st page freshly

Debarpita, I'm afraid I don't quite understand the requirement still.

When the button on the second popup is clicked, if we execute the code in the UI Action all over again, then it's an infinite loop right.

UI Action -> UI Page 1 -> UI Page 2 -> Back to UI Action...

 

From your screenshot I see you are doing some search related stuff. If you could explain one last time what is the client requirement, rather than your current design, I or @Ankur Bawiskar will be able to help you better.

 

Fingers crossed 🙂

Hi Anirudh,

UI Action -> UI Page 1 -> UI Page 2 -> Back to UI Action-> display the ui page only->end