Aug 25, 2022 08:52 AM
Hello to all,
I would like to be able to copy every day at a precise time the data contained in a column and paste it in another column.
This is to compare the progress each day with the day before.
Would you have an idea?
I was going to use an automation but I can’t find the solution.
Thanks a lot,
A.
Aug 25, 2022 09:16 PM
Hi @Production2
Hmm, I’m thinking you could either:
Aug 26, 2022 01:18 AM
Thank you for your answer :winking_face:
I’ve got a Pro Account but I don’t know how to write this script to make your second proposal.
Aug 27, 2022 01:26 AM
Hey @Production2,
If you’ve got the time and automations to burn through, I’d really advise going with the first option if you’re not familiar with scripting. That way you can make changes and stuff without relying on anyone else
If you’re really set on going down the scripting road, DM me a link to your base as well as the name of the column you want copied and the column to copy into and I’ll see what I can do
Aug 29, 2022 08:16 AM
You can link the table to new ‘copier’ 1-record table linked to all records, set lookups or rollups and copy to other field (or 7 fields for week/30 fro month) with no code, pure automation
or use that template to copy all column. Set 3 values.
const table=base.getTable(' Set table name ');
const [SRC,DEST]=[' Set_source_field ,' Set_destination_field '];
const upd=await table.selectRecordsAsync({fields:[SRC]}).then(q=>
q.records.map(r=>({'id':r.id,'fields':{[DEST]:r.getCellValue(SRC)}})))
while(upd.length) await table.updateRecordsAsync(upd.splice(0,50))
note that it copy text to text.
if your Source fieldtype is multi/single-select, lookup or something ‘more complex’, you need to change [DEST]:r.getCellValue(SRC) to
.getCellValueasString(SRC) - to read ‘complex value’ as usual string
in worst case, when you need to write to ‘complex field’, you need additional converting
Aug 29, 2022 09:06 AM
Hello @Alexey_Gusev,
Thank you for this answer.
Indeed it is about copying a lookup field with a duration.
(I want to know the duration progression between 2 days)
When I try your template I’ve got this error message :
ERROR
Syntax error: Unexpected identifier [script.js:2:25]
const table=base.getTable(’ Set table name ‘);
const [SRC,DEST]=[’ Set_source_field ,’ Set_destination_field '];
const upd=await table.selectRecordsAsync({fields:[SRC]}).then(q=>
q.records.map(r=>({‘id’:r.id,‘fields’:{[DEST]:r.getCellValueasString(SRC)}})))
while(upd.length) await table.updateRecordsAsync(upd.splice(0,50))
Aug 29, 2022 12:19 PM
Sorry for my cognitive bias, I expect it to be obvious and told it, as if I explain to another coder. Also, my English is far from perfect.
You should set 3 values: your table name and field names here, like this:
Also, use getCellValueasString(SRC)
to read Lookup field as string
destination field should be writable (not Lookup), and preferably SingleText or LongText.
Aug 30, 2022 05:41 AM
Hello,
Thank you very much for your answer.
After several tests the script works but only between two single text fields :frowning:
Despite trying to modify the script with getCellValueasString(SRC) I still have an error
TypeError: r.getCellValueasString is not a function
at on line 3
at on line 3
at async main on line 3
For info my source is a Duration Rollup with condition field and my destination is a Duration field
Dec 27, 2023 07:41 PM
You can also use a no-code alternative for this use case by utilizing a third party that integrates with Airtable. We have created an extension that will allow you to automatically copy values from one field to another.