Have a script that combines url+title - Need edit for multiple url & titles in each field

Hello,

I have a company review database. On Table 1 is the Companies. Table 2 has the Reviews of those companies, with links to those individual entries. Each company has multiple reviews submitted by various people.

I have linked Companies to Reviews, done a lookup for the url + title I want (from Reviews). The script I have transforms those into hyperlinks successfully., but ONLY if there is only 1 url and 1 title in those fields.

Because each company has multiple reviews submitted by different people, each field has multiple entries (both url and title), and my script is resulting in one run-on link that shoved all the titles together. Any ideas how to edit this script to separate each of these out?

I used:

let tb2 = base.getTable("Companies");
let query2 = await tb2.selectRecordsAsync();
for (let record of query2.records) {
    let url = record.getCellValue("Individual Rating links (from Reviews)");
    let text = record.getCellValue("Job Title (from Reviews)");
    if(url) {
        tb2.updateRecordAsync(record, {"Rich Text Individual Ratings": `[${text}](${url})`})
    }
}

Thanks in advance!

Hi Sadie, try this

let tb2 = base.getTable("Table 1");
let query2 = await tb2.selectRecordsAsync();
for (let record of query2.records) {
    let url = record.getCellValue("Individual Rating links (from Reviews)");
    let text = record.getCellValue("Job Title (from Reviews)");
    if(url) {
        let textToUse = ""
        for (let i = 0; i < url.length; i++){
            textToUse = textToUse + '[' + text[i] + '](' + url[i] + '),'
        }
        tb2.updateRecordAsync(record, {"Rich Text Individual Ratings": textToUse})
    }
}

You can find it set up in a base here

This topic was solved and automatically closed 15 days after the last reply. New replies are no longer allowed.