Help

Upcoming database upgrades. Airtable functionality will be reduced for ~15 minutes at 06:00 UTC on Feb. 4 / 10:00 pm PT on Feb. 3. Learn more here

Inner join between attachment url

Solved
Jump to Solution
141 2
cancel
Showing results for 
Search instead for 
Did you mean: 

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). 4.PNG

Total primary is: 

5.PNG

and Total 2 is: 

6.PNG

This is the result that I obtained: 

7.PNG

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() 
  })
}

 

 

 

8.PNG

 

What did I do wrong 😰?  Thank you very much for any help! 

1 Solution

Accepted Solutions

@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].

See Solution in Thread

2 Replies 2

@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].

Thank you very much!! That was the problem!