UI Page, redirect when page is loading
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2016 06:47 AM
I have a UI Page. Before page loads, I need to make a redirect based on condition.
I tried something like this, but didn't work.
<g:evaluate jelly="true">
var v = new GlideRecord("myTable");
v.addQuery("sys_id",jvar_XXXX)
v.query();
v.next();
if(!v.field)
{
gs.sendRedirect("/redirect to anothe ui page");
}
</g:evaluate>
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2016 06:57 AM
Hi Nick,
You could do something like this where you do the lookup in the jelly code and then redirect using javascript:
<g:evaluate jelly="true">
var url = '';
var v = new GlideRecord("myTable");
v.addQuery("sys_id",jvar_XXXX)
v.query();
if (v.next())
{
url = v.something;
}
</g:evaluate>
<script>
document.observe("dom:loaded", function() {
window.location = '${url}';
});
</script>
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2016 07:02 AM
I thought about using js, but i would like a solution without usign js.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2016 07:07 AM
That pretty much the standard way to do a redirect with a ui page. Why don't you want to use js?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2016 07:11 AM
I suppose you could do it with a meta tag as well:
<g:evaluate jelly="true">
var url = '';
var v = new GlideRecord("myTable");
v.addQuery("sys_id",jvar_XXXX)
v.query();
if (v.next())
{
url = v.something;
}
</g:evaluate>
<meta http-equiv="refresh" content="2;url=${url}" />