ServiceNow use 'getDisplayValue' in GlideAggregate
var sQuery='status=1^profile!=NULL';//--status=active
var sTable='x_cls_clear_skye_i_account';
var sField='profile';
var iCountValue=1;
var dupls=checkDupl (sQuery, sField, sTable, iCountValue);
gs.print(dupls);
function checkDupl(customQuery, fieldParam, table, iCountValue){
var ga= new GlideAggregate(table);
ga.addAggregate('COUNT', fieldParam);
ga.orderByAggregate('count', fieldParam);
ga.orderBy(fieldParam);
if (customQuery){
ga.addQuery(customQuery);
}
ga.addHaving('COUNT', '>', iCountValue);
ga.query();
var dupls=[];
dupls.push("The following " + ga.getRowCount() + " records have matching on " + fieldParam + ": " );
while (ga.next()) {
var DuplLine=ga.getAggregate('COUNT', fieldParam) + " => " +
ga.getElement(fieldParam) + "; " + ga.getDisplayValue(fieldParam);
dupls.push(DuplLine);
//break;
}
//gs.log(dupls,'duplWidget_arr');
return dupls;
}
output:
*** Script: The following 13585 records have matching on profile: ,6 => be3be1f7873f511044f1da8bbbbbxxxx; Rainer T
Comments
Post a Comment