May 17, 2024 10:41 AM
I suspect this is a super easy thing to do, but I have been googling for over an hour now and all attempt to make this script function is seemingly failing.
const { recordId } = input.config();
const table = base.getTable('tbliyrxpGU6tkQgG7');
let record = await table.selectRecordAsync(recordId);
let user = record.getCellValue("Requestor (Airtable)");
console.log(user)
await table.updateRecordAsync(recordId, { "Requestor (AT)": { id: user }});
Requestor (Airtable) is a Lookup Field that is pulling in a User.
Requestor (AT) is a (Single) User field.
The console log shows that 'user' is indeed an object that has id, email, name. But no matter how I try to pass the user onto the actual user field, it won't take it. "Cannot accept the provided value."
Solved! Go to Solution.
May 17, 2024 02:10 PM
@byrnes , I prefer to use email address for identifying who asked for things. This is alway unique and can be used to filter interface views for people who do have accounts. For example
May 19, 2024 11:51 PM
Hm, not sure if you've already resolved this, but maybe try this?
const { recordId } = input.config();
const table = base.getTable('tbliyrxpGU6tkQgG7');
let record = await table.selectRecordAsync(recordId);
let user = record.getCellValue("Requestor (Airtable)")[0];
console.log(user)
await table.updateRecordAsync(recordId, { "Requestor (AT)": { id: user }});
May 20, 2024 04:47 AM
I'm not sure why I needed it compared to yours, but yours got me there. I had to add a .id on user to make it work.
const { recordId } = input.config();
const table = base.getTable('tbliyrxpGU6tkQgG7');
let record = await table.selectRecordAsync(recordId);
let user = record.getCellValue("Requestor (Airtable)")[0];
console.log(user)
await table.updateRecordAsync(recordId, { "Requestor (AT)": { id: user.id }});
Thank you everyone!