Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to redirect back to particular view with UI Action click

mballinger
Mega Guru

Hello,

How can I redirect a user back to a particular view after a UI Action is clicked? I want them to land on the same record, but I want their views to change? 

This is the UI Action I have:

function closeTicket() {
   var dialogWindow = new GlideDialogWindow('incident');
   dialogWindow.setTitle("Close Ticket");
   
   dialogWindow.setPreference('sysparm_incident', g_form.getUniqueValue());

   dialogWindow.setWidth(850);
   dialogWindow.render();
}

Thanks!

1 ACCEPTED SOLUTION

I guess you missed the quotes:

var url = 'incident.do?sys_id=' + incident + '&sysparm_view=default';
response.sendRedirect(url);

View solution in original post

5 REPLIES 5

@Ankur Bawiskar - Thanks for your response.

In the UI Page, there are a few lines that handle the redirect

Processing Script:

var url = 'incident.do?sys_id=' + incident; //Incident is already defined in script
response.sendRedirect(url);

I tried the following and it did not seem to work:

var url = 'incident.do?sys_id=' + incident + '&sysparm_view=default'; 
response.sendRedirect(url);

The purpose of the redirect is to take them from the view that they were currently in, and transition them to a different view