- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2016 07:26 PM
Hi all,
Our Pilot users have discovered that when they do not have any active tickets, they cannot go in and see their inactive tickets
After all requests / incidents are closed, the menu item disappears.
Is there a way to make the menu item stay visible, even when there are no active tickets?
The code for the menu item (this is OOB)
var t = data; // shortcut
t.items = [];
t.count = 0;
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.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);
t.count++;
}
}
var z = new GlideRecord('incident');
z.addActiveQuery();
z.addQuery('caller_id', gs.getUserID());
z.orderByDesc('sys_updated_on');
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);
t.count++;
}
var z = new GlideRecord('sc_request');
z.addActiveQuery();
z.addQuery('requested_for', gs.getUserID());
z.orderByDesc('sys_updated_on');
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.hasNext())
a.short_description = ritm.getRowCount() + ' requested items';
else
a.short_description = ritm.cat_item.getDisplayValue() || ritm.getDisplayValue("short_description");
a.__table = z.getTableName();
a.type = 'request';
a.sortOrder = z.sys_updated_on.getGlideObject().getNumericValue();
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 requests');
link.type = 'link';
link.href = '?id=requests';
link.items = [];
t.items.unshift(link); // put this first
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2016 12:43 AM
item.showAlways should probably be item.scriptedItems.showAlways
When you declare property in a javascript object, it will be created. You don't have to worry about the property already existing.
If you want to be sure that the property actually exist you could do a console.log("MY DEBUG: " + item.scriptedItems.showAlways);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2017 03:38 PM
var t = data; // shortcut
t.items = [];
t.count = 0;
t.showAlways = true;
Then in the template add this attribute to the if
6. <a ng-if="item.scriptedItems.count > 0 || item.scriptedItems.showAlways" href="javascript:void(0)" data-toggle="dropdown" title="{{item.hint}}"> <!-- this allows the menu item to show
This should be the correct answer, not the one stated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2016 12:43 AM
item.showAlways should probably be item.scriptedItems.showAlways
When you declare property in a javascript object, it will be created. You don't have to worry about the property already existing.
If you want to be sure that the property actually exist you could do a console.log("MY DEBUG: " + item.scriptedItems.showAlways);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-06-2016 04:14 AM
Cheers Lars, that did the trick.
I really appreciate your help today, and I am starting to get a hang of this javascript stuff.
Thanks again, and if you are ever in Sydney give me a shout - ill buy you a beer!
Cheers,
Brendan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-20-2017 01:57 AM
Hi All,
I tried with the mentioned steps but it is not working.
Below is the code
Menu Item
// maximum number of entries in this Menu
var max = 30;
var t = data; // shortcut
t.items = [];
t.showAlways=true;
menuTemplate
<a ng-if="item.scriptedItems.count > 0 || item.scriptedItems.showAlways" href="javascript:void(0)" data-toggle="dropdown" title="{{item.hint}}">
<span ng-bind-html="item.label"></span>
Thanks,
Chandrashekar BN
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-26-2017 09:43 PM
Hey Chandra,
What version are you on? after updating to Jakarta Patch 4, this has stopped working and now I am back to the drawing board.
Cheers,
Brendan