Hello, folks, i am trying to change the filename for files in an attachment field, and i noticed that when there are a few records it seems like the names get changed, but when i try to process more than 30, the attachments automatically get removed. I also noticed that the comments in the records id indicate that two actions have taken place
But for the ones that worked it shows just one time the record has been edited
The script that i use is below, i noticed a similar behavior when i was trying to upload attachments from a URL as well, some get updated, while some do not.
// Define the table, view, and field names
const tableName = 'StuTable';
const viewName = 'StuMissingcert';
const attachmentFieldName = 'medicalupload';
const studentIDFieldName = 'id';
// Select the table, view, and get the records
const table = base.getTable(tableName);
const view = table.getView(viewName);
const records = await view.selectRecordsAsync();
// Iterate through the records
for (let record of records.records) {
// Get the attachment field data and student ID
const attachments = record.getCellValue(attachmentFieldName);
const studentID = record.getCellValue(studentIDFieldName);
// Check if there are attachments
if (attachments && attachments.length > 0) {
// Replace the file names with the student ID
const updatedAttachments = attachments.map(attachment => {
// Use the student ID as the new file name
const newFileName = studentID;
return {
url: attachment.url,
filename: newFileName
};
});
// Update the record with the new file names
await table.updateRecordAsync(record, {
[attachmentFieldName]: updatedAttachments
});
}
}