
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2017 09:25 AM
I am trying to use UI Action ("Posts") to navigate to a new form within a scoped application but it doesn't work. It actually goes back to the list.
The var URL is properly populated because the list is displayed when I copy and paste it directly into a browser tab.
UI Action: Posts
Action name: add_posts
Show insert/update: true
Client: true
Form button: true
function getPosts() {
// save records
current.update();
// Prepare the URL for "Take me to the Information"
/* var instance = gs.getProperty("instance_name"); */
var instance = '<myinstance>';
var URL1 = 'https://' +instance;
var URL2 =
'.service-now.com/x_conym_gov_post_list.do?sysparm_first_row=1&sysparm_query=u_request%3D';
var request = g_form.getValue('u_request');
var URL3 = '&sysparm_view';
// Build final URL
var URL = URL1 +URL2 +request +URL3;
alert("URL = " +URL );
action.setRedirection(URL);
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2017 09:36 AM
I totally missed the fact that you have client checked. You have (mostly) server side code in your script. Uncheck client and try this script instead. You cannot mix server side objects (like current and action) with client scripts in this manner.
// save records
current.update();
var URL1 = 'x_conym_gov_post_list.do?sysparm_first_row=1&sysparm_query=u_request%3D';
var request = current.getValue('u_request');
var URL2 = '&sysparm_view';
// Build final URL
var URL = URL1 +request +URL2;
gs.addInfoMessage(URL);
action.setRedirectURL(URL);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2017 09:29 AM
The syntax is:
action.setRedirectURL(url)
or
action.setRedirectURL(GlideRecord object); // example. current)

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2017 09:31 AM
Hi Armin,
Try below script
function getPosts() {
// save records
current.update();
var x = new GlideRecord('x_conym_gov_post_list');
x.addQuery('u_request',current.u_request);
x.query();
if (x.next())
action.setRedirection(x);
}
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2017 09:36 AM
I totally missed the fact that you have client checked. You have (mostly) server side code in your script. Uncheck client and try this script instead. You cannot mix server side objects (like current and action) with client scripts in this manner.
// save records
current.update();
var URL1 = 'x_conym_gov_post_list.do?sysparm_first_row=1&sysparm_query=u_request%3D';
var request = current.getValue('u_request');
var URL2 = '&sysparm_view';
// Build final URL
var URL = URL1 +request +URL2;
gs.addInfoMessage(URL);
action.setRedirectURL(URL);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-24-2017 09:45 AM
Hi Chuck,
That did the trick. Thank you.
Armin