vennila ramasamy
05/11/2023, 8:05 AMNathan L
05/11/2023, 2:55 PMlet subsidiaryObj = {}; // initialized an object that we will use to group eveything by subsidiary
// run the saved search and loop through the results
savedSearchObj.run().each((result) => {
// get the subsidiary from the result
let subsidiary = result.getValue({ name: 'subsidiary' });
// if the subsidiary is not in the object, add it
if (!subsidiaryObj[subsidiary]) {
subsidiaryObj[subsidiary] = [];
}
// push the result id to the array
subsidiaryObj[subsidiary].push(result.id);
});
In this scenario after the search loop runs you would have an object named subsidiaryObj that lists each unique subsidiary as a key with the value being an array of record id's from the search