Instance Scan checks List Layout with more than one List Element on the same position

aditi__patil
Tera Expert

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