Jun 27, 2024 10:23 AM
Hello,
This is a variant on an earlier topic. I have a base where users input lengthy URLs into several fields, and corresponding display text in separate fields. I've been using the workaround where a formula field does this calculation:
[Airtable
whereas my formula approach gives Airtable
Here's the automation script I'm using. Any advice is greatly appreciated!
let inputConfig = input.config();
let theURL = inputConfig.theURL;
let displayName = inputConfig.website;
let recordID = inputConfig.recordID;
let thisTable = base.getTable('Table 1');
let blank="";
let markup = blank.concat("[", displayName, "](",theURL, ")");
await thisTable.updateRecordAsync(recordID, {
"website" : markup
})
output.set(markup, "marked up");
Solved! Go to Solution.
Jun 27, 2024 11:07 AM - edited Jun 27, 2024 11:08 AM
Ok I was able to work it out. I'm not actually sure what the problem was because I changed a couple of things at once. Here's my solution:
1) Set the "Simple name" and "URL" fields to one line text. Website is a long text with rich text formatting. Create a calculation that's the time difference between modifications
DATETIME_DIFF(LAST_MODIFIED_TIME(URL, {Simple name}), LAST_MODIFIED_TIME(website))
2) Create an automation triggered by the calculated time exceeding some number. I set it to 0:00.1. That might need to be tweaked later depending on how Airtable backend does things, so I'll monitor that
3) Create a script as such:
let inputConfig = input.config();
let theURL = inputConfig.theURL;
let displayName = inputConfig.SimpleName;
let recordID = inputConfig.recordID;
let thisTable = base.getTable('Table 1');
let blank="";
let markup = blank.concat("[", displayName, "](",theURL, ")");
console.log(markup)
await thisTable.updateRecordAsync(recordID, {
"website" : markup
})
Jun 27, 2024 10:24 AM
On a side note, this type of URL construction seems like a basic feature that Airtable should support better. I see requests for this going back to 2016. Is there a wishlist this could be bumped up on?
Jun 27, 2024 11:07 AM - edited Jun 27, 2024 11:08 AM
Ok I was able to work it out. I'm not actually sure what the problem was because I changed a couple of things at once. Here's my solution:
1) Set the "Simple name" and "URL" fields to one line text. Website is a long text with rich text formatting. Create a calculation that's the time difference between modifications
DATETIME_DIFF(LAST_MODIFIED_TIME(URL, {Simple name}), LAST_MODIFIED_TIME(website))
2) Create an automation triggered by the calculated time exceeding some number. I set it to 0:00.1. That might need to be tweaked later depending on how Airtable backend does things, so I'll monitor that
3) Create a script as such:
let inputConfig = input.config();
let theURL = inputConfig.theURL;
let displayName = inputConfig.SimpleName;
let recordID = inputConfig.recordID;
let thisTable = base.getTable('Table 1');
let blank="";
let markup = blank.concat("[", displayName, "](",theURL, ")");
console.log(markup)
await thisTable.updateRecordAsync(recordID, {
"website" : markup
})