var gr = new GlideRecord('your_table_name'); // Replace with your table name
gr.orderByDesc('amount'); // Sort in descending order
gr.query();
var firstLargest = null;
var secondLargest = null;
if (gr.next()) {
firstLargest = gr.amount; // Get the largest value
}
if (gr.next()) {
secondLargest = gr.amount; // Get the second largest value
}
gs.info('Second largest amount: ' + secondLargest);
Second largest value in the amount field using GlideRecord in ServiceNow
Working Code Asked question September 17, 2024
Sorry, you do not have permission to read comments.