Dec 14, 2022 01:07 PM
Hi, I'm trying to do an inner join between two columns and print in a new column (only the attachments that are in common in both columns). The problem is that the columns have attachment URLs, I tried to use the Script that @Andrey_Kovalev suggested to me for just text, but it just prints me the first element or anything.
Those are the two columns that I'm trying to merge (Total Primary and Total 2).
Total primary is:
and Total 2 is:
This is the result that I obtained:
For example Sara should have Test 3 and Test 1, but She has only Test 1.
This is the code that I tried to use with automation:
//collect input
let Rec = input.config()
//load records
let table = base.getTable("Users")
let record = await table.selectRecordAsync(Rec.RecID)
//declare inner join array
let innerJoin2 = []
//function for filtering unique array entries
function onlyUnique(value, index, self) {
return self.indexOf(value) === index;
}
//check existence of the record and not empty arrays
if(record !== null &&
record.getCellValueAsString("Total Primary") !== "" &&
record.getCellValueAsString("Total 2") !== "")
{
//variables declaration
let array3 = record.getCellValueAsString("Total Primary").split(",")
let array4 = record.getCellValueAsString("Total 2").split(",")
//check if entries of array3 exist in array4
for(let entry of array3){
if(array4.includes(entry)){
innerJoin2.push(entry)
}
}
//filter unique array entries
innerJoin2 = innerJoin2.filter(onlyUnique)
//update InnerJoin field with contents of innerJoin array
await table.updateRecordAsync(Rec.RecID, {
"innerJoin2": innerJoin2.toString()
})
}
What did I do wrong 😰? Thank you very much for any help!
Solved! Go to Solution.
Dec 16, 2022 05:32 AM
@Sara , I can see that in your example a comma is missing between Test 2 and Test 3 links. That is why Test 3 can not be distinguished as an array entry. The array looks like [Test 1, Test 2 Test 3, Test 1].
Dec 16, 2022 05:32 AM
@Sara , I can see that in your example a comma is missing between Test 2 and Test 3 links. That is why Test 3 can not be distinguished as an array entry. The array looks like [Test 1, Test 2 Test 3, Test 1].
Dec 19, 2022 05:47 AM
Thank you very much!! That was the problem!