mg2017
04/16/2024, 4:31 PMverikott
04/16/2024, 4:32 PMmg2017
04/16/2024, 4:41 PM| ${targetValue}${destinationTagEnd}
);
log.debug({title: "updatedAddtlNtryInf", details: updatedAddtlNtryInf});
fileContent = fileContent.substring(0, rmtInfStart) + updatedAddtlNtryInf + fileContent.substring(endIndex + destinationTagEnd.length);
log.debug("Updated Tag Value");
} else {
log.debug("Couldn't find closing tag for the AddtlNtryInf following Cash Pooling");
}
break;
}
startIndex = acSvcrRefEnd + "</AcctSvcrRef>".length; // Move to next AcctSvcrRef
}
if (!targetValue) {
log.debug({title: "No matching AddtlRmtInf found for Cash Pooling"});
return;
}
// Save the updated file
const updatedFile = file.create({
name: myFile.name, fileType: myFile.fileType, contents: fileContent, folder: myFile.folder,
});
const updatedFileId = updatedFile.save();
log.debug({title: "Updated File ID", details: updatedFileId});
});
}
function getFileIDFromSearch(search) {
log.debug("Here 1");
const savedSearchId = 'customsearch_my_files_lookup';
log.debug(savedSearchId);
const fileSearch = search.load({
id: savedSearchId
});
log.debug("Here 2");
const filesToModify = [];
fileSearch.run().each(function (result) {
// Get the file ID from the search result
const fileId = result.getValue({
name: "internalid", join: "file",
});
log.debug({title: "File ID", details: fileId});
const fileName = result.getValue({
name: "name", join: "file"
});
log.debug({title: "File Name", details: fileName});
const fileToModify = checkFile(fileName);
log.debug({title: "File Requires Modification", details: fileToModify});
if (fileToModify) {
filesToModify.push(fileId);
}
return true;
});
return filesToModify;
}
function checkFile(fileName) {
const lowerCaseFileName = fileName.toLowerCase();
return lowerCaseFileName.includes('ldn'); // Return true if the file name contains 'ldn'
}verikott
04/16/2024, 4:42 PMmg2017
04/16/2024, 4:45 PMerictgrubaugh
04/16/2024, 5:44 PMgetFileIDFromSearch
from outside the entry point, and that typically generates an error indicating that you can't do thaterictgrubaugh
04/16/2024, 5:45 PMerictgrubaugh
04/16/2024, 5:57 PMexecute
function is not what is assigned to the entry point. Since I cannot see the whole module, I am making several assumptions based solely on the name of that functionalien4u
04/16/2024, 8:20 PMcheckFile(fileName)
, then guessing here (because the code you shared is not complete), you are iterating over those file IDs with a `forEach`:
⢠each file load
is going to consume governance as well as each getContent
call.
⢠break
is not valid in a forEach
and/or it would not do what you think it should.mg2017
04/16/2024, 11:41 PM