Community Alums
Not applicable

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'

 

find_real_file.png

 

Secondly, select the Table name as 'Configuration Item' and Menu 'List header' and in Condition restrict it to admin role.

 

find_real_file.png

 

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.

find_real_file.png

 

Let me know if you guys face any issues.

Cheers,

Hardit Singh

Version history
Last update:
‎03-19-2019 03:04 AM
Updated by:
Community Alums