(Connect this to the ‘Accept’ Button)
// Accept Submission Script
// Last Updated: Aug 28, 2022
let table = base.getTable("👻 Anonymous Q&A Channel");
// Prompt the user to pick a record
// If this script is run from a button field, this will use the button's record instead.
let record = await input.recordAsync('Select a record to use', table);
if (record) {
let currentStatus = record.getCellValue("Status")
if (currentStatus == null) {
table.updateRecordAsync(record, {'Status': "Accepted"});
output.text(`✅ The following submission was successfully posted: ${record.getCellValue("Submission")}`);
} else {
output.text(`❌ This record cannot be posted because it has already been reviewed. This submission has already been accepted or rejected.`);
}
} else {
output.text('No record was selected');
}
(Connect this to the ‘Reject’ Button)
// Reject Submission Script
// Last Updated: Aug 28, 2022
let table = base.getTable("👻 Anonymous Q&A Channel");
// Prompt the user to pick a record
// If this script is run from a button field, this will use the button's record instead.
let record = await input.recordAsync('Select a record to use', table);
if (record) {
let currentStatus = record.getCellValue("Status")
if (currentStatus == null) {
table.updateRecordAsync(record, {'Status': "Rejected"});
output.text(`🛑 The following submission was rejected: ${record.getCellValue("Submission")}`);
} else {
output.text(`❌ This record cannot be posted because it has already been reviewed. This submission has already been accepted or rejected.`);
}
} else {
output.text('No record was selected');
}