Dec 27, 2022 04:17 PM
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
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
Can you help me create an automation for this case?
Thank you in advance
Dec 30, 2022 03:22 AM
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 :
I hope it helps!
Dec 30, 2022 03:24 AM
@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
Jan 01, 2023 03:21 AM
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.
Jan 08, 2023 10:24 PM
@dreamchaserses let me know above solved the issue? If yes you can mark it as a solution. Thanks!