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

AnirudhKumar
Mega Sage

In order to switch views, you just have to add an extra parameter in your redirect URL called sysparm_view, and give the name of your view:

 

g_navigation.open('/incident.do?sys_id=d05bf3002f6330108d3fe36ef699b61a&sysparm_view=workspace');

@AnirudhKumar - Thanks for your response. 

I didn't realize there was a UI Page, but in the UI Page, there is a redirect happening through the processing script:

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

I tried your suggesting and adding the 'sysparm_view=default', but it did not work

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

I guess you missed the quotes:

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

Ankur Bawiskar
Tera Patron

Hi,

can you share your entire UI action script.

It seems you are calling UI page and doing some processing there

Regards
Ankur

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