Hi,
i have two tables.
- Keywords (2 Views: 1st “All records”, 2nd “Records without topic”)
- Topics
After importing new keywords to the Keywords Table i 'm using a script to link all keywords without a topic to a topic which i define while i’m running the script.
The first time i’m using the script - f.e. i’ve just imported 3 Keywords (Keyword 1, Keyword 2, Keyword 3) and after that running the script to link them to “Topic 1” of the Topics Table - everything works as expected.
But if i import another set of keywords (Keyword 4, Keyword 5, Keyword 6) and run the script again - again i like to link all of the just imported keywords to “Topic 1” - the first three keywords of the first import gets unlinked from topic 1 and the new imported keywords gets linked to “Topic 1” instead.
Seems i’m making a mistake in the script but i have no clue what to do to make it work.
Could anybody help me out here? Thanks a lot.
Kai
This is the script i’m using
//Keywords einem Thema zuordnen//
let topicsTable = base.getTable(‘Topics’);
let topicsRecord = await input.recordAsync(“Wähle ein Thema, dass den Keywords zugeordnet werden soll”,topicsTable)
let keywordsTable = base.getTable(‘Keywords’).getView(‘Keywords without topic’);
let keywordsQuery = await keywordsTable.selectRecordsAsync();
let keywordsRecords = keywordsQuery.records;
let d =
keywordsRecords.forEach(c => d.push({id: c.id}));
await topicsTable.updateRecordAsync(topicsRecord.id,{
'Keywords': d
}
);
output.markdown(’# Erledigt ’)
Here is the link to my test base: Sign up - Airtable