Save the date! Join us on October 16 for our Product Ops launch event. Register here.
Mar 07, 2022 09:11 AM
Hello Guys !
Trying again,
I’ve set up this script founded on this forum !
My goal is to input the company logo automatically when the user puts the website url.
The problem is,
when the website’s url isn’t recognized, the automation keeps running and running and consumes all the automations :frowning:
What can I add to my script to stop the automation run after a minute for example (meaning that the website isn’t recognized) ?
Here is the script :
console.log( Hello, ${base.name}!
);
let table = base.getTable(‘Expériences’);
let query = await table.selectRecordsAsync();
for (let record of query.records) {
// if the attachment field is empty
if(record.getCellValue(‘Logo’) == null && record.getCellValue(‘Site internet’) != null) {
let recordId = await table.updateRecordAsync(record, {
‘Logo’: [
{ url: ‘[https://logo.clearbit.com/’+record.getCellValue('Site ](https://logo.clearbit.com/’+record.getCellValue('Site) internet’)}
]
})
}
}
Thank for the help
Agathe
Mar 07, 2022 09:21 AM
This script looks at all of the records in the entire table. You probably want a different script that only updates the single triggering record, instead of trying to process all of the records in the table.
You also might need to adjust the trigger for the automation so that it only runs when there is a complete url. If you are simply looking for a value in the url field, Airtable will think it has a value as soon as the first character is typed.
The forum software may also be messing up the formatting of your code. The value that you are using to update the Logo
field looks strange to me.
Mar 07, 2022 09:36 AM
Hi Kuovonne !
Yes indeed.
I’im not the creator of this script haha
I found it on airtable but not able to modify it because I’m very bad at data entry. ^^
Mar 07, 2022 12:26 PM
Now you know somebody who’s bad at coding too. Welcome to the community!
This script needs to mark the process as complete whether it succeeds or fails such that it prevents follow-on attempts.
Mar 08, 2022 12:08 AM
Yes but no I have no idea how to complete my script ^^
Mar 08, 2022 12:20 AM
I don’t know scripting, but there are non-scripting ways of accomplishing this as well.
You can use MiniExtensions to convert your URLs into attachments:
And you can also use an automation tool such as Zapier or Make to do the same thing. (I’ve only done this before using Make, but I’m assuming that Zapier can do the same thing.)
Mar 09, 2022 09:36 AM
Is your goal to simply have the logo in the attachment field, or is part of your goal to learn how to write scripts?
The fastest way to the original goal (logo in attachment field) is by not fixing the script yourself. Either invest in MiniExtensions or hire someone to write the script for you.
On the other hand, if your goal includes learning scripting, I suggest that you take a step back. The proper way to fix your script is not to add code that stops the script from running. There are other issues in your script that are problematic. You would be better off starting from scratch and gradually building up your skills to a script that does what you want and only what you want.
Mar 11, 2022 12:00 AM
Hi!
I should probably do i t with make ! Easier with no-code because I’m not able to find out the good script