
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-13-2017 01:26 PM
Hi,
I need to automatically set the view=self-service when navigating to an REQ from the 'Requests' menu item in Service Portal:
https://ceisandbox1.service-now.com/ceisp?id=sc_request&table=sc_request&sys_id=b41f7da84f6d76008b81...&view=self-service
Currently, when I click on an item from that menu item, it does not set the view parameter in the URL.
Is there a way to append the view parameter to the URLs returned from this scripted list menu item? I wasn't able to see where the URL is being generated in the server script on that menu item:
// maximum number of entries in this Menu
var max = 30;
var t = data; // shortcut
t.items = [];
var u = gs.getUser().getID();
// use record watchers to tell header when to update dropdown counts
t.record_watchers = [];
t.record_watchers.push({'table':'service_task','filter':'active=true^opened_by=' + u});
//t.record_watchers.push({'table':'incident','filter':'active=true^caller_id=' + u});
t.record_watchers.push({'table':'sc_request','filter':'active=true^requested_for=' + u});
var st = new GlideRecord('service_task');
if (st.isValid()) {
st.addActiveQuery();
st.addQuery('opened_by', gs.getUserID());
st.orderByDesc('sys_updated_on');
st.setLimit(max);
st.query();
while (st.next()) {
var a = {};
$sp.getRecordValues(a, st, 'short_description,sys_id,number,sys_updated_on');
if (st.short_description.nil())
a.short_description = "(No description)";
a.__table = st.getTableName();
a.type = 'record';
a.sortOrder = st.sys_updated_on.getGlideObject().getNumericValue();
t.items.push(a);
}
}
/*
var z = new GlideRecord('incident');
z.addActiveQuery();
z.addQuery('caller_id', gs.getUserID());
z.orderByDesc('sys_updated_on');
z.setLimit(max);
z.query();
while (z.next()) {
var a = {};
$sp.getRecordValues(a, z, 'short_description,sys_id,number,sys_updated_on');
if (z.short_description.nil())
a.short_description = "(No description)";
a.__table = z.getTableName();
a.type = 'record';
a.sortOrder = z.sys_updated_on.getGlideObject().getNumericValue();
t.items.push(a);
}
*/
var z = new GlideRecord('sc_request');
z.addActiveQuery();
z.addQuery('requested_for', gs.getUserID());
z.orderByDesc('sys_updated_on');
z.setLimit(max);
z.query();
while (z.next()) {
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request', z.getUniqueValue());
ritm.query();
//if (!ritm.next())
// continue;
var a = {};
$sp.getRecordValues(a, z, 'sys_id,number,sys_updated_on');
if (ritm.next())
a.short_description = ritm.cat_item.getDisplayValue();
else
a.short_description = ritm.getDisplayValue("short_description") || z.getDisplayValue("short_description");
a.__table = z.getTableName();
a.type = 'request';
a.sortOrder = z.sys_updated_on.getGlideObject().getNumericValue();
t.items.push(a);
}
t.items.sort(function(a, b) {
return b.sortOrder - a.sortOrder;
});
t.items = t.items.slice(0, max); // only want first 30
t.count = t.items.length;
var link = {title: gs.getMessage('View all requests'), type: 'link', href: '?id=requests', items: []};
t.items.unshift(link); // put 'View all requests' first
Regards,
Chris Perry
Solved! Go to Solution.
- Labels:
-
Service Portal Development

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2017 08:04 AM
Hi Shembop,
I actually was able to figure this one out a while back, sorry for not posting my solution earlier! Here's what I did:
1. Type 'sp_ng_template.list' into your filter navigator, this will bring up the list of angular templates in your instance
2. Locate the 'spDropdownTreeTemplate' record
3. Depending on the ticket type for which you are trying to specify a view, locate the relevant line of code and update the 'href=' to include the view parameter as shown in the screenshot below:
After taking the steps above, users should automatically redirect to the specified view when clicking on a ticket from the menu drop down in service portal.
Thanks,
Chris
Regards,
Chris Perry

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2017 08:04 AM
Hi Shembop,
I actually was able to figure this one out a while back, sorry for not posting my solution earlier! Here's what I did:
1. Type 'sp_ng_template.list' into your filter navigator, this will bring up the list of angular templates in your instance
2. Locate the 'spDropdownTreeTemplate' record
3. Depending on the ticket type for which you are trying to specify a view, locate the relevant line of code and update the 'href=' to include the view parameter as shown in the screenshot below:
After taking the steps above, users should automatically redirect to the specified view when clicking on a ticket from the menu drop down in service portal.
Thanks,
Chris
Regards,
Chris Perry

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2017 08:06 AM
Hi Shannon,
Sorry I hadn't responded to your post earlier, please see my response to Shembop for the correct answer.
Thanks,
Chris
Regards,
Chris Perry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-28-2017 06:21 AM
Christopher,
Glad to see that you are using the Community to learn more.
The Customer Experience team is striving to ensure that customer queries posted from the HI Service Portal are answered in timely and accurate fashion.
If you feel your question has been resolved, please mark the appropriate reply in the thread as being the Correct Answer.
This enables other customers to learn from your thread.
Thank you in advance.
If you are viewing this from the community inbox you will not see the correct answer button. If so, please review How to Mark Answers Correct From Inbox View.
Regards,
Teena Singh
Customer Experience: UX Strategy and Customer Insights
teena.singh@servicenow.com
ServiceNow