Instance Scan checks List Layout with more than one List Element on the same position
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-03-2025 07:29 AM
I am trying to make an instance scan check such that it checks lists with more than one element at same position from sys_ui_list_element table.
I have made a table check with the following script but am unable to get the correct findings. Please review
(function(finding) {
var gr = new GlideRecord('sys_ui_list_element');
finding.setCurrentSource(gr);
gr.query();
var listIdMap = {};
while (gr.next()) {
var listId = gr.getValue('list_id');
var position = gr.getValue('position');
if (!listIdMap[listId]) {
listIdMap[listId] = [];
}
listIdMap[listId].push(position);
}
for (var listId in listIdMap) {
var positions = listIdMap[listId];
var positionCount = {};
var hasDuplicates = false;
for (var i = 0; i < positions.length; i++) {
if (positionCount[positions[i]]) {
positionCount[positions[i]]++;
hasDuplicates = true;
} else {
positionCount[positions[i]] = 1;
}
}
if (hasDuplicates) {
finding.increment();
}
}
})(finding);
0 REPLIES 0