- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2022 12:44 AM
Hi All,
I'm creating a notification Menu Item same as in csm portal, but i'm getting error that Function getGlideObject is not allowed in scope x_case.
Please help to correct my code-
---------------------------------------------------------------------------------------------------
var t = data; // shortcut
t.record_watchers = [];
var u = gs.getUser().getID();
var t = data;
t.items = [];
t.count = 0;
t.record_watchers.push({'table':'x_case','filter':'stateIN400^contact=' + u});
var z = new GlideRecord("x_case");
z.addQuery("contact", u);
z.addQuery("state", 'IN', '400');
z.orderByDesc('sys_updated_on');
//z.setLimit(1);
z.query();
while (z.next()) {
var a = {};
$sp.getRecordValues(a, z, 'sys_id,sys_updated_on');
a.number = z.getDisplayValue();
a.__table = z.getRecordClassName();
a.__page = 'x_cases';
a.type = 'record';
a.sortOrder = z.sys_updated_on.getGlideObject.getNumericValue();---> ERROR
t.items.push(a);
t.count++;
}
t.items.sort(function(a, b) {
return b.sortOrder - a.sortOrder;
});
var link = {};
link.title = gs.getMessage('View all notifications');
link.type = 'link';
link.href = '?id=x_notification';
link.items = [];
t.items.unshift(link);
------------------------------------------------------------------------------------------------------------------
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-27-2022 09:48 PM
Hi,
please use this
Use GlideDateTime and then use getNumericValue()
a.sortOrder = new GlideDateTime(z.sys_updated_on).getNumericValue();
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2022 01:09 AM
Hi,
getGlideObject is not supported in the scoped applications instead use the below code to get the numeric value of sys_updated_on
var updatedOn = new GlideDateTime(z.sys_updated_on);
a.sortOrder = updatedOn.getNumericValue();
//If you want the numeric value in seconds
var durationInSeconds = updatedOn.getNumericValue()/1000;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2022 01:27 AM
Hi Sai,
Now I'm getting this error - Server JavaScript error "updateOn" is not defined. and error on a.sortOrder = updateOn.getNumericValue();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2022 01:28 AM
Hi,
use this
a.sortOrder = z.sys_updated_on.getNumericValue();
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-25-2022 01:32 AM
Hi Ankur,
getting this error on Portal-
Server JavaScript error Cannot find function getNumericValue in object 2022-03-25 08:23:20.
a.sortOrder = z.sys_updated_on.getNumericValue(); - Error