I’m using a script that generates a QR code as an attachment.
Here’s the structure.
The script that I use (shared by someone here) will:
1. Generate QR codes for the record as an attachment.
2. If this record already has an attachment, skip it.
// Change the names of this table/fields according to your base.
let submissionsTable = base.getTable('⚙️ Realizacja');
let urlField = submissionsTable.getField('barcodes4.me [URL]');
let attachmentField = submissionsTable.getField('QR Customer');
let submissionsQuery = await submissionsTable.selectRecordsAsync();
let updates = [];
for (let record of submissionsQuery.records) {
let url = record.getCellValue(urlField);
let attachments = record.getCellValue(attachmentField);
// If this record already has an attachment, skip it.
if (attachments !== null) {
continue;
}
// Otherwise, attach the image at the URL.
updates.push({
id: record.id,
fields: {
[attachmentField.id]: [{url: url}]
}
});
}
// Update records in batches of 50.
while (updates.length > 0) {
await submissionsTable.updateRecordsAsync(updates.slice(0, 50));
updates = updates.slice(50);
}
How to modify the script so it would only generate the QR for a specific record and not all?
I get a hint in AT but entirely sure how to do it.
Record from button field was not used
This script did not use the record from the button field. To use a record from a button field, call input.recordAsync in your script.
Don't show again