
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2020 09:10 AM
We are trying to figure out why HR Admins are unable to delete multiple HR Case records from the list view using the "Actions on selected rows..." drop-down list. They can delete a record if they are in it, just not multiple. The role is on the "Delete" ACL for the table so they have the access to delete records using the UI Action button in the record.
We would like for them to have the ability to delete multiple but only from the HR Core Case Table and not any other tables.
When on the list view they can see the option in the "Actions on selected rows..." drop-down list but is grayed out.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2023 09:44 AM
I found a solution to this and coming back here as I realized I could include it so that it may help someone else.
I ended up creating a new UI Action for the HR Case table copied from another UI Action that does the same/similar for other tables. This UI Action while on the HR Case table is applied to the Global scope but also takes into account the conditions if the user can delete (from Delete ACL) and has the HR Admin role. This way they do not have the ability to delete multiple records from other tables in the Global Scope such as Incident as an example. NOTE: this had to be done from the Global Scope and NOT from within the HR scope so keep that in mind.
Below is a screenshot of the values I used for the UI Action and the script.
var tblName;
var ajaxHelper;
var selSysIds;
var sysIdList;
var indx = 0;
var numSel = 0;
function confirmAndDeleteFromList() {
tblName = g_list.getTableName();
selSysIds = g_list.getChecked();
sysIdList = selSysIds.split(',');
numSel = sysIdList.length;
if (numSel > 0) {
indx = 0;
ajaxHelper = new GlideAjax('DeleteRecordAjax');
getCascadeDeleteTables();
}
}
function getCascadeDeleteTables() {
if (sysIdList[indx] != '') {
ajaxHelper.addParam('sysparm_name', 'getCascadeDeleteTables');
ajaxHelper.addParam('sysparm_obj_id', sysIdList[indx]);
ajaxHelper.addParam('sysparm_table_name', tblName);
ajaxHelper.addParam('sysparm_nameofstack', null);
ajaxHelper.getXMLAnswer(getCascadeDelTablesDoneList.bind(this), null, null);
}
}
function getCascadeDelTablesDoneList(answer, s) {
var delObjList = '';
var selObjName = '';
if (answer != '') {
var ansrArray = answer.split(';');
if (ansrArray.length > 1) selObjName = ansrArray[1];
if (ansrArray.length > 2) delObjList = ansrArray[2];
}
if (delObjList != '') {
if (numSel > 1) {
showListConfDlg("true", selObjName, delObjList);
} else {
showListConfDlg("true", '', delObjList);
}
} else {
indx++;
if (indx < numSel) {
ajaxHelper.addParam('sysparm_name', 'getCascadeDeleteTables');
ajaxHelper.addParam('sysparm_table_name', tblName);
ajaxHelper.addParam('sysparm_obj_id', sysIdList[indx]);
ajaxHelper.getXMLAnswer(getCascadeDelTablesDoneList.bind(this), null, null);
} else {
showListConfDlg("false", '');
}
}
}
function showListConfDlg(hasCascadeDel, selObjName, delObjList) {
var dialogClass = typeof GlideModal != 'undefined' ? GlideModal : GlideDialogWindow;
var dlg = new dialogClass('delete_confirm_list');
dlg.setTitle('Confirmation');
if (delObjList == null) {
dlg.setWidth(300);
} else {
dlg.setWidth(450);
}
dlg.setPreference('sysparm_obj_list', selSysIds);
dlg.setPreference('sysparm_table_name', tblName);
dlg.setPreference('sysparm_has_cascade_del', hasCascadeDel);
dlg.setPreference('sysparm_sel_obj_name', selObjName);
dlg.setPreference('sysparm_del_obj_list', delObjList);
dlg.render();
}
After selecting the records to delete they can go into the "Actions on selected rows..." drop-down list and the 'Delete' option is no longer greyed out and they will get a Confirmation pop-up prompt, "Delete the selected record(s)" with the options to 'Cancel' or 'Delete'. Depending on the number of records to delete it may take a few seconds to see the prompt so just be patient. 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-04-2020 02:12 PM
if one item is selected, is the option to delete not grayed out?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-05-2020 01:03 PM
No even if one is selected it is still grayed out. The only way they are able to delete is if they open and go into the record and then they can delete using the delete button.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-21-2023 09:44 AM
I found a solution to this and coming back here as I realized I could include it so that it may help someone else.
I ended up creating a new UI Action for the HR Case table copied from another UI Action that does the same/similar for other tables. This UI Action while on the HR Case table is applied to the Global scope but also takes into account the conditions if the user can delete (from Delete ACL) and has the HR Admin role. This way they do not have the ability to delete multiple records from other tables in the Global Scope such as Incident as an example. NOTE: this had to be done from the Global Scope and NOT from within the HR scope so keep that in mind.
Below is a screenshot of the values I used for the UI Action and the script.
var tblName;
var ajaxHelper;
var selSysIds;
var sysIdList;
var indx = 0;
var numSel = 0;
function confirmAndDeleteFromList() {
tblName = g_list.getTableName();
selSysIds = g_list.getChecked();
sysIdList = selSysIds.split(',');
numSel = sysIdList.length;
if (numSel > 0) {
indx = 0;
ajaxHelper = new GlideAjax('DeleteRecordAjax');
getCascadeDeleteTables();
}
}
function getCascadeDeleteTables() {
if (sysIdList[indx] != '') {
ajaxHelper.addParam('sysparm_name', 'getCascadeDeleteTables');
ajaxHelper.addParam('sysparm_obj_id', sysIdList[indx]);
ajaxHelper.addParam('sysparm_table_name', tblName);
ajaxHelper.addParam('sysparm_nameofstack', null);
ajaxHelper.getXMLAnswer(getCascadeDelTablesDoneList.bind(this), null, null);
}
}
function getCascadeDelTablesDoneList(answer, s) {
var delObjList = '';
var selObjName = '';
if (answer != '') {
var ansrArray = answer.split(';');
if (ansrArray.length > 1) selObjName = ansrArray[1];
if (ansrArray.length > 2) delObjList = ansrArray[2];
}
if (delObjList != '') {
if (numSel > 1) {
showListConfDlg("true", selObjName, delObjList);
} else {
showListConfDlg("true", '', delObjList);
}
} else {
indx++;
if (indx < numSel) {
ajaxHelper.addParam('sysparm_name', 'getCascadeDeleteTables');
ajaxHelper.addParam('sysparm_table_name', tblName);
ajaxHelper.addParam('sysparm_obj_id', sysIdList[indx]);
ajaxHelper.getXMLAnswer(getCascadeDelTablesDoneList.bind(this), null, null);
} else {
showListConfDlg("false", '');
}
}
}
function showListConfDlg(hasCascadeDel, selObjName, delObjList) {
var dialogClass = typeof GlideModal != 'undefined' ? GlideModal : GlideDialogWindow;
var dlg = new dialogClass('delete_confirm_list');
dlg.setTitle('Confirmation');
if (delObjList == null) {
dlg.setWidth(300);
} else {
dlg.setWidth(450);
}
dlg.setPreference('sysparm_obj_list', selSysIds);
dlg.setPreference('sysparm_table_name', tblName);
dlg.setPreference('sysparm_has_cascade_del', hasCascadeDel);
dlg.setPreference('sysparm_sel_obj_name', selObjName);
dlg.setPreference('sysparm_del_obj_list', delObjList);
dlg.render();
}
After selecting the records to delete they can go into the "Actions on selected rows..." drop-down list and the 'Delete' option is no longer greyed out and they will get a Confirmation pop-up prompt, "Delete the selected record(s)" with the options to 'Cancel' or 'Delete'. Depending on the number of records to delete it may take a few seconds to see the prompt so just be patient. 🙂