- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 03-19-2019 03:04 AM
Hope you guys are having an awesome day. I recently was assigned an Enhancement which had a requirement of providing access to 'Update All' functionality to Asset Management team. But, OOB it would have allowed Asset Management team to see 'Update All' UI Context Menu on all forms.
Rather then providing them this access, I decided to create new similar 'Update All Asset' UI Context Menu which will be available only to asset management team on CI tables.
To achieve this, I firstly created a new UI Context Menu with the name 'Update All Asset'
Secondly, select the Table name as 'Configuration Item' and Menu 'List header' and in Condition restrict it to admin role.
Finally, my favorite part: Coding
In the 'Action Script' write the following code
runContextAction();
function runContextAction() {
var url = new GlideURL(g_list.tableName + '_update.do');
url.addParam('sys_action', 'sysverb_multiple_update');
url.addParam('sysparm_multiple', 'true');
url.addParam('sysparm_nostack', 'yes');
url.addParam('sysparm_query', g_list.getQuery({fixed: true}));
url.addParam('sysparm_view', g_list.getView());
var msg = ['Update the entire list?', 'records'];
var answer = new GwtMessage().getMessages(msg);
if (!confirm(answer['Update the entire list?'] + " (" + g_list.grandTotalRows + " " + answer['records'] + ")"))
return;
window.location = url.getURL();
}
And in onShow script
var query = g_list.getQuery();
var ga_set = new GlideAjax('CIListAjax');
ga_set.addParam('sysparm_name','setQuery');
ga_set.addParam('sysparm_query',query);
ga_set.getXML(setData);
function setData(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
}
The new UI context menu will start appearing on you CI list as soon as you save it.
Let me know if you guys face any issues.
Cheers,
Hardit Singh
- 935 Views