Help

How to Create Different Records from Long Line Text Separated by Commas

Topic Labels: Automations
1504 7
cancel
Showing results for 
Search instead for 
Did you mean: 
kreeshteli
4 - Data Explorer
4 - Data Explorer

Hello all,

Within my team's workflow, there are two tables, a campaign and task table, that we use a good amount. One of the fields on the campaign table is a "Deliverables Needed" column where a campaign owner would list out the deliverables needed and separate each deliverable that is needed by commas. 

Currently, I have an automation where if a campaign record matches the conditions of having the "Deliverables Needed" not empty, a new task is created with the name of the deliverables needed field from the campaign table. My problem comes when I want a new task created for each deliverable separated by commas rather than the whole field. 

For example if for one of the campaigns, the "Deliverables Needed" field has "Article, Press Release, Stories," there will be only one task created named "Article, Press Release, Stories." I instead want a new task for "Article", another one for "Press Release," and then a third one for "Stories." I also have other fields I want filled out, but I am sure with this base script I can be able to figure the rest out hopefully. 

I am not too much of an expert with scripts, the one automation I have right now was made through the help of Airtable. I also have other fields I want to be filled out for the task record when its created, but I am sure with this base script, I can be able to figure the rest out, hopefully. Thank you for your help in advance! 

7 Replies 7

Hi @kreeshteli,

For a non-scripting approach, you can convert this field into a multi-select field and use this field as the input list for a Repeating Group automation step to do a Create Record action per multi-select option selected. Your trigger could be when a status changes or when a checkbox button is checked, etc.

Hope that helps!
-Stephen

Sho
11 - Venus
11 - Venus

Hello,

For example, a simple script that divides by "," and returns in a list.

let taskList = [];
input = input.config();
input.list.split(',').forEach( function( value ){
taskList.push(value);
})
output.set("list",taskList);

It works in testing, but in practice, using this script causes various problems.

 For more complex things, learn Javascript or hire an expert😊

Hi,
regadless of current input.config() configuration, assuming let {list, other_input_variable, ...}=input.config(), I would write

 

let taskList=list.split(',')
output.set("list",taskList)

when I realized such details, it made JS programming much more enjoyable for me 🙂

 

Oh, I was processing in vain! Thanks.

input = input.config();
output.set("list", input.list.split(','));

@kreeshteli Great answers above from everyone! Alternatively, for a no-code way of splitting a long text field into an array (which you can then create multiple records from), Make offers a split function.

Hey thanks for the help!

I am trying a code like this, but for some reason, it keeps saying, "Property 'fields' does not exist on type '{}'." Any ideas on how to approach this problem?


// Assuming 'campaign' is the source table and 'task' is the destination table

const campaign = input.config();
const deliverablesNeeded = campaign.fields['Deliverables Needed'];

if (deliverablesNeeded) {
const campaignRecord = campaign.fields['Campaigns'][0]; // Assuming it's a single linked record
const campaignId = campaignRecord.id;
const deliverables = deliverablesNeeded.split(',').map(deliverable => deliverable.trim());

deliverables.forEach(async deliverable => {
const newTask = {
'Name': deliverable, // Replace 'Name' with the actual field name in the task table
'Campaigns': [{ id: campaignId }],
'Type': 'Deliverable',
// Add other relevant task fields here
};

// Create a new task in the task table
await input.table('Tasks').createRecordAsync(newTask);
});
}

Hi, 
Please clarify - is it scripting extension or automation script step?
input.config() - is an object of input data usually used at a start of automation
to assign a table to a variable in scripting extension, you should do smth like

const campaign=base.getTable('SomeTable')


You can achieve your goal without scripting with repeating actions, as suggested above.
Also, when you put string  'Test1,Test2,Test3' in a linked field, and linked table has no such values in a primary field, it will create a record for each.
But If you are comfortable with scripting, you need to try. Take a look at examples in scripting editor window - it might help with simple operations syntax