Joining columns together in the same data source

Hi

What’s the simplest way to join values from the same data source columns together. In this example, there is a ‘first name’ and a ‘last name’ column as that data is used throughout the app but I would also like to be able to use a full name value in a typeahead field.

I started to look at concatenating it in the screen JS but started to feel a bit queasy, is there a way of it being handled in the data source itself maybe?

Hi Nathan

You should use javascript code to concatenate the name string when displaying the name. But if you are doing this many times you could use a form hook to concatenate it into a new field when the name is written to the data source by the form.

To concatenate before submission use the beforeSubmit hook and set a full name field. For example:

data.["Full name"] = data.["First name"]+data.["Last name"]

Once a new key is added to the data object it will appear as a new col in the data source.

That’s really handy. I’ve got it working using that method. I created the ‘Full name’ column in the data source and it is now populated when users register, using their first and last name. Here’s the final code:

Fliplet.Hooks.on('beforeFormSubmit', function(data) {
  data["Full name"] = data["First name"] + ' ' + data["Last name"]
});
2 Likes

Thanks for the update and sharing the code for others. I am glad to hear it’s working.