You can create a custom Data Hook® to split 2 fields by a specific value.
Let's consider an example - a person's first name and last name are both inside the same row under the firstName field. We can use the code snippet below to evaluate if there is a space (" ") between values in that row. If there is, then the code snippet below will automatically separate those 2 values into firstName and lastName fields by a specific value of a space (" ").
if (
row['firstName'] && !row['lastName']
) {
if (
row['firstName'].includes(" ")) {
const components = row['firstName'].split(" ");
row['firstName'] = components.shift();
row['lastName'] = components.join(" ");
}
}
return { row, info: [] }
This code example is for data hooks in Portal 2.0. For an example of how to do this in Portal 3.0 or Workspaces, see our "Split Column" example in the Data Hooks tab of your template.