Since my saved search is sorted in ascending order, failed items stay at the top. To skip them after rescheduling, I use a script parameter (failedjecount) to track the number of failed items and adjust the saved search start and end indices accordingly.
Updated Function: var getMoreRecords = function(transactionSearchObj, failedjecount) { var startPos = faileditemcount; var endPos = 50 + faileditemcount; var resultSet = transactionSearchObj.run(); return resultSet.getRange({ start: startPos, end: endPos }) || []; };
Script Logic:
Fetch failedjecount from the script parameter.
Skip failed items using failedjecount in the search.
Process records and count new failed items.
Update failedjecount and reschedule.
This approach skips failed items, tracks them efficiently, and avoids infinite rescheduling.