Splitting concatenated values and saving each to a new record

Hi folks,

We have some data that has come into our application as a concatenated list of values, and we would like to extract each value and save to a new table and new record for each value. We know Tadabase has the text utilities pipe with the split function, but saving the pipe response doesn’t save each value individually. There are some other community posts about saving duplicate copies of records or how to concatenate or aggregate values, but so far, have not found a solution on how to de-aggregate values. Any guidance would be appreciated, thanks!

If it were me, I’d do that function outside of Tadabase, which I’m sure is probably something you’re reluctant to to. I’d personally use MAKE (Integromat) to iterate through the values and update Tadabase with the results. I’ve been using Tadabase with MAKE for a few years now and there are something that I just find a lot easier to achieve with MAKE.

I’d echo what Greddie is saying. I actually use both Zapier and Make for various jobs like this alongside Tadabase. Whilst there would be a way to do this by writing your own script within Tadabase, its easier and safer to use Make… its a really solid tool for this task.

1 Like

Hi, maybe you can try with a Custom JavaScript Pipe, using this code:

/**
 * Required parameters to be included as variables in Tadabase:
 * {APP_ID} - Your Tadabase application ID
 * {API_KEY} - Your Tadabase API key
 * {API_SECRET} - Your Tadabase API secret
 * {CHILD_TABLE_ID} - The ID of the child table where new records will be created
 * {CONCATENATED_LIST} - The concatenated list of values from the previous step in Tadabase
 * {FIELD_ID} - The field ID in the child table where the value will be stored
 */

function processConcatenatedList() {
  // Replace with your Tadabase API endpoint
  var childApiUrl = 'https://api.tadabase.io/api/v1/data-tables/{CHILD_TABLE_ID}/records';

  // The concatenated list passed from the previous step in Tadabase
  var concatenatedList = '{CONCATENATED_LIST}';

  // Split the concatenated list into an array of values
  var values = concatenatedList.split(',');

  // Iterate through each value, trim it, and create a new child record in the new table
  values.forEach(function(value) {
    var trimmedValue = value.trim();
    createChildRecord(trimmedValue, childApiUrl);
  });
}

function createChildRecord(value, apiUrl) {
  var payload = {
    "{FIELD_ID}": value  // Replace "{FIELD_ID}" with the actual field ID you want to update
  };

  var options = {
    'method': 'post',
    'contentType': 'application/json',
    'headers': {
      'X-Tadabase-App-Id': '{APP_ID}',
      'X-Tadabase-App-Key': '{API_KEY}',
      'X-Tadabase-App-Secret': '{API_SECRET}'
    },
    'payload': JSON.stringify(payload)
  };

  try {
    var response = UrlFetchApp.fetch(apiUrl, options);
    Logger.log('Child record created: ' + response.getContentText());
  } catch (error) {
    Logger.log('Error creating child record: ' + error.toString());
  }
}

We are thinking the values are separated with “,” if not, use the right separator to trim

3 Likes

Thanks for this! Where would you suggest running this pipe? As a table rule on the parent table? or as an Action rule?

Well, the logic move is to create a table rule in the parent table, every time a record is created, you trigger the pipe to create the child records

I suggest using Zapier or Integromat. Both provide user-friendly and secure interfaces.