mg2017
03/01/2022, 4:59 PMvar file_count = file_search.runPaged().count;
file_search.run().each(function (result) {
internal_id = result.getValue({
name: 'internalid',
});
file_id = result.getValue({
name: 'internalid',
join: 'file'
});
log.debug({title: 'File ID', details: file_id});
log.debug({title: 'Number of files found', details: file_count});
for (var i = 1; i < file_count; i++) {
log.debug({title: "Current Count", details: i})
if (i < 11) { //attachment limit is 10
if (file_id) {
file_collection.push(file.load({
id: file_id
}))
}
}
}
log.debug({title: "Total Count", details: i})
const folder_id = 1933298;
var _file_obj = file.load({
id: file_id
});
log.debug("Move PDF File To Archived Folder");
_file_obj.folder = folder_id;
_file_obj.save();
return true;
});
Testing with 11 files. I expect it to attach the first 10 then stop.
battk
03/01/2022, 5:08 PMbattk
03/01/2022, 5:09 PM(var i = 1; i < file_count; i++)
battk
03/01/2022, 5:09 PMbattk
03/01/2022, 5:09 PMbattk
03/01/2022, 5:10 PMbattk
03/01/2022, 5:10 PMmg2017
03/01/2022, 11:54 PMfor (var i = 0; i < file_count; i++) {
log.debug({title: "Current Count", details: i})
if (i === 11) { //attachment limit is 10
break;
if (file_id) {
file_collection.push(file.load({
id: file_id
}))
}
}
}
mg2017
03/01/2022, 11:56 PMbattk
03/01/2022, 11:56 PMbattk
03/01/2022, 11:57 PMmg2017
03/02/2022, 12:01 AMbattk
03/02/2022, 12:03 AMbattk
03/02/2022, 12:03 AMbattk
03/02/2022, 12:04 AMmg2017
03/02/2022, 12:46 AM