- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2016 09:27 AM
Hi guys I am encountering the below error when creating a new record.
The code below would update the Number of Requests on the Header Menu whenever a record is saved (current user):
The code is located in Service Portal Menu header-> Menu Items. Type = Scripted List.
var st = new GlideRecord('myTable');
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, 'request_description,sys_id,number,sys_updated_on'); This is where the error is occuring
if (st.request_description.nil())
// a.short_description = st.request_description;
a.__table = st.getTableName();
a.type = 'record';
// a.sortOrder = st.sys_updated_on.getGlideObject().getNumericValue();
t.items.push(a);
}
}
This code works perfectly for the Incident table. But for some reason is not working in my custom table. Any idea why?
Solved! Go to Solution.
- Labels:
-
User Interface (UI)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2016 11:29 AM
No fix. An evangelist told me to open a HI ticket with ServiceNow.
I know this doesn't solve your problem, but it's a start.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-29-2016 06:44 AM
No problem. Please mark this as answered.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-13-2018 05:47 AM
reginabautista cmcclendon - Did either of you get an answer for this from HI? I am running into this issue as well in Kingston patch 1 in a scoped app.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-14-2018 06:05 AM
No answer. I have seen a few workarounds attempted, but this must be low on the totem pole.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2018 06:45 AM
You should note that the $sp scoped version is called "GlideSPScriptable".
https://docs.servicenow.com/bundle/kingston-application-development/page/app-store/dev_portal/API_reference/GlideSPScriptableScoped/concept/c_GlideSPScriptableScopedAPI.html
I however had an issue with "Scripted List" menu items that made $sp calls. Even replacing "$sp" with "GlideSPScriptable" didn't fix the issue (Kingston.p2) due to some kind of internal script sourcing issue (according to Hi support).
The recommendation for now is to only work on those problematic menu items in the global scope.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2018 06:22 AM
I've been working around this issue by replacing:
$sp.getRecordValues(a, st, 'request_description,sys_id,number,sys_updated_on');
with:
a.request_description = st.request_description.getDisplayValue();
a.sys_id = st.sys_id.getDisplayValue();
a.number = st.number.getDisplayValue();
a.sys_updated_on = st.sys_updated_on.getDisplayValue();