URGENT Help- Function getGlideObject is not allowed in scope Error

ST9
Tera Contributor

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);

------------------------------------------------------------------------------------------------------------------

1 ACCEPTED SOLUTION

Hi,

please use this

Use GlideDateTime and then use getNumericValue()

a.sortOrder = new GlideDateTime(z.sys_updated_on).getNumericValue();

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

View solution in original post

6 REPLIES 6

Hi,

please use this

Use GlideDateTime and then use getNumericValue()

a.sortOrder = new GlideDateTime(z.sys_updated_on).getNumericValue();

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

It is working, ty.