Skip to main content

Hello,

I have a table with a file field, there I also have a “file url” field where I add the expiring downlad url of that file. As this url expire after 2 hours, I search for a solution to update this url every 2 hours so it stay available.

 

I tried with automations first : Tried a repetition group but the problem is that all I can do is add the whole list of url (separated with comma) from all the records, i cannot find how to add the url of this record only.

 

For exemple I want to have :

File url of record 1 = url 1

File url of record 2 = url 2

File url of record 3 = url 3

 

But what I have is :

File url of record 1 = url 1, url 2, url 3

File url of record 2 = url 1, url 2, url 3

File url of record 3 = url 1, url 2, url 3

 

So I tried with scripts, I found a script extension that work perfectly (its named “Convert attachments to URLs”) but I cannot find how to execute it automatically every 2 hours.

 

So I tried the “run script” option in automations, but it seem I can’t connect scripts from extension to that “run script” block. And when I tried to copy the code of that script, I fall on a error saying me “TypeError: selectedView.selectRecordsAsync is not a function”.

 

So I’m starting to feel out of option to do that, do you maybe have a idea of how I can accomplish that ?

 

Thanks in advance !

HI,

adjust first 2 lines and put in automation
 

const table=base.getTable('TABNAME') //set table name here
const FLD1,FLD2]=='Attachments','URL'] //set field names
const query=await table.selectRecordsAsync({fields::FLD1]})
const urls=arr=>arr.map(f=>f.url).join(',')
const nonempty=r=>r.getCellValue(FLD1)!==null
const update=r=>({id:r.id,fields:{{FLD2]: urls(r.getCellValue(FLD1))}})
const upd=query.records.filter(nonempty).map(update)
console.log(`Updating ${upd.length} records...`)
while (upd.length) await table.updateRecordsAsync(upd.splice(0,50))

 


Well, im sorry for this post, seem like I found the issue of why my script didnt worked in the “run script” block.

 

I replaced “selectedView.selectRecordsAsync” by “selectedTable.selectRecordsAsync “ and the script worked.

 

I set the automation on a 2 hours schedule to see if it will really work as intended and will see.

 

Sorry for the inconvenience, seem like I always find the answer by myself just after I ask for help 😅