Help

Re: Split a Long-Text cell from Table 1 into multiple cells in Table 2

1367 0
cancel
Showing results for 
Search instead for 
Did you mean: 
dreamchaserses
4 - Data Explorer
4 - Data Explorer

Hello Community!

I have a form to submit records to "Table 1". Two of the fields from this form are Long-Text fields called "Anchors1" and "Links1" where I input multiple lines of text. In example, "Anchors1" cell content is:

"Anchor 1
Anchor 2
Anchor 3"

And "Links1" cell content is:

"link1.com
link2.com
link3.com"

Example of the form: https://airtable.com/shrSx7xeaXqXIfGBy

Example of Table1: https://airtable.com/shrXWKgXuwV0sx2cw

dreamchaserses_0-1672186610970.png

 

I want to run an automation, that every time the form is submitted ( and a new record is created on "Table 1") I can get the data from the last record created in "Table 1" and split the records from  fields "Anchors1" and "Links1" into many different records on Table 2.

The result should be 3 new records on Table 2, where in Field "IndividualAnchors1" and "IndividualLink1" I can Get:

Record ID  |  IndividualAnchors1   |   IndividualLink1

ID1              |  Anchor 1                     |   link1.com
ID2             |  Anchor 2                    |   link2.com
ID3             |  Anchor 3                    |   link3.com

Example of Table2 with the splitted content: https://airtable.com/shrWD03FklpPRRAst

dreamchaserses_1-1672186648526.png

 

 

Can you help me create an automation for this case?


Thank you in advance

 

4 Replies 4

Are the form submissions submitted always in pairs of 3?

If yes, you could use automation

 a) create 3 Regex Fields for "anchors" and 3 Regex Fields for "Links"

b) run automation  with trigger when form submitted, and 3x action create record

Above solution is bit crude but might work.

 

Best option would be probably Automation and Script:
a) when record is submitted - run script
b) use following script

const table2 = base.getTable("Table 2")

const {anchors , links} = input.config()

const anchorsRow = anchors.split("\n")
const linksRow = links.split("\n")


for (let [index,row] of Object(anchorsRow).entries() ){
  
    await table2.createRecordAsync({
        "Anchor": row,
        "Link":  linksRow[index+1] 
    })
}

  With variables like this :

Greg_F_0-1672399313936.png

I hope it helps!

@dreamchaserses I did not do IDs in the script -> I think it would be easier to use Autonumber and concatenate with ID in the first column

Lom_Labs
7 - App Architect
7 - App Architect

Hello, we've built an app for this exact purpose and you can find it here.

The app will generate a script that you can add to your "Run a Script" automation action, and the script will  split the long text from multiple cells in the first table and create records in the second table, as well as linking the records together.

It does not matter how many data fields you have, so if you have the fields "IndividualAnchors1", "IndividualAnchors2", "IndividualAnchors3", "IndividualLink1", "IndividualLink2" for the same record, the app will still work fine.

Combine Fields and Create Records.gif

@dreamchaserses  let me know above solved the issue? If yes you can mark it as a solution. Thanks!