Export Context Menu in List View
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2025 01:47 AM
Use Case:
I want to hide export context menu from my custom tables if the logged in user is not member of a specific group.
I have added this line in the Export Context menu Condition:
!ListProperties.isRelatedList() && !ListProperties.isRefList() && new TestSI().disableExport(ListProperties.getTable())
Script Include:
disableExport: function(tableName) {
var groupID = gs.getProperty('Allowed_GroupID');
var tablesHidden = ['custom_table1', 'custom_table2', 'custom_table3', 'custom_table4', 'custom_table5'];
if(tablesHidden.indexOf(tableName) != -1) {
return gs.getUser().isMemberOf(groupID);
} else {
return true;
}
},
Currently its not working.
I have tried putting logs but after a time the logs are not showing even if i refresh the list view.
Need help.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2025 02:17 AM
I hope you already overrode the OOTB export button for your custom table
update it as this
Note: I assume the system property contains comma separated sysIds of group
disableExport: function(tableName) {
var groupID = gs.getProperty('Allowed_GroupID'); // I assume this contains comma separated sysIds of group
var tablesHidden = ['custom_table1', 'custom_table2', 'custom_table3', 'custom_table4', 'custom_table5'];
if (tablesHidden.indexOf(tableName) != -1) {
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group.sys_id", "IN", groupID);
gr.addQuery("user", gs.getUserID());
gr.setLimit(1);
gr.query();
return gr.hasNext();
} else {
return true;
}
},
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2025 04:27 AM
groupID containts only 1 sysID
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2025 05:18 AM
then script shared by me should work fine for 1 sysId or more than 1
if you will always keep 1 sysId then no script include required
Simply use this
!ListProperties.isRelatedList() && !ListProperties.isRefList() && gs.getUser().isMemberOf(gs.getProperty('Allowed_GroupID'))
if in future that property might get updated with more than 1 then use script include
disableExport: function(tableName) {
var groupID = gs.getProperty('Allowed_GroupID'); // I assume this contains comma separated sysIds of group
var tablesHidden = ['custom_table1', 'custom_table2', 'custom_table3', 'custom_table4', 'custom_table5'];
if (tablesHidden.indexOf(tableName) != -1) {
var gr = new GlideRecord("sys_user_grmember");
gr.addQuery("group.sys_id", "IN", groupID);
gr.addQuery("user", gs.getUserID());
gr.setLimit(1);
gr.query();
return gr.hasNext();
} else {
return true;
}
},
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-02-2025 05:18 AM
when i override the OOTB export button in my custom tables, does this mean I will have 2 export buttons for my custom table?
Thanks.