Comment Post Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Jan 18, 2023 11:38 PM
I'm currently running a script button that will copy the 'Reservation Requested By' value to 'Reserved for' value.
let table = base.getTable("Status Report");
let record = await input.recordAsync('Reservation Requested By', table);
if (record) {
let oldValue = record.getCellValueAsString("Reservation Requested By");
let newValue = oldValue;
output.text(newValue);
await table.updateRecordAsync(record,{"Reserved for": newValue});
} else {
output.text('');
}
I want to add a condition to this button so that if the 'reserved for' value is not empty, or exceeds certain days then remove the value.
Can I do that?
1 Reply 1
Comment Post Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Jan 21, 2023 01:21 PM
Here is one approach you could consider - we're checking if the "Reserved for" field is empty, and if it is - then we take the "Reservation Requested By" info and stamp it into the "Reserved for".
let table = base.getTable("Status Report");
let record = await input.recordAsync('Reservation Requested By', table);
if (!record?.getCellValueAsString("Reserved for")) {
let newValue = record?.getCellValueAsString("Reservation Requested By")
await table.updateRecordAsync(record ,{"Reserved for": newValue});
};
