My surveys in menu header only showing surveys in ready state
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2018 05:33 AM
Hi All
in the menu header on my portal i have added in My surveys, however it is only showing surveys that are in the ready state, i want to show those that are also in progress. i think there are two places i need to amend my script, but i can't get it to work (i've not done any scripting courses) I'm sure it's simple, but i don't know how, looking for any suggestions please.
Existing script is;
// 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':'asmt_assessment_instance','filter':'state=ready'});
var z = new GlideRecord('asmt_assessment_instance');
z.addActiveQuery();
z.addQuery('user', gs.getUserID());
z.addQuery('state', 'ready');
z.orderByDesc('sys_updated_on');
z.setLimit(max);
z.query();
while (z.next()) {
/*var a = {};
$sp.getRecordValues(a, z, 'sys_id,instance_id,metric_type,state');
a.__table = z.getTableName();
a.type = 'record';
a.__page = 'take_survey';
a.short_description = z.metric_type.name + " " + z.task_id.number;
a.sortOrder = z.sys_updated_on.getGlideObject().getNumericValue();*/
var a = {title: z.metric_type.name + " " + z.task_id.number, type:
'link', href: '?id=take_survey&instance_id=' + z.sys_id, items: []};
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;
Thanks
- 1,458 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-07-2018 10:14 AM
Hi,
Please make corrections in following Line.
Existing script is;
// 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':'asmt_assessment_instance','filter':'state=ready'}); change to
t.record_watchers.push({'table':'asmt_assessment_instance'});
var z = new GlideRecord('asmt_assessment_instance');
z.addActiveQuery();
z.addQuery('user', gs.getUserID());
//z.addQuery('state', 'ready'); //comment this line
z.orderByDesc('sys_updated_on');
z.setLimit(max);
z.query();
while (z.next()) {
/*var a = {};
$sp.getRecordValues(a, z, 'sys_id,instance_id,metric_type,state');
a.__table = z.getTableName();
a.type = 'record';
a.__page = 'take_survey';
a.short_description = z.metric_type.name + " " + z.task_id.number;
a.sortOrder = z.sys_updated_on.getGlideObject().getNumericValue();*/
var a = {title: z.metric_type.name + " " + z.task_id.number, type:
'link', href: '?id=take_survey&instance_id=' + z.sys_id, items: []};
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;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2018 06:33 AM
Hi,
Any Update?
Thanks,
Bhojraj
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2018 07:11 AM
Hi,
It didn't work, not sure why.
Thanks

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2018 07:54 AM