Inserting custom / calculated columns

I’m wondering what the best method is to programmatically insert a column into a table.

For example, if I have a datetime column in my database, but I wanted to display it as two separate date / time columns. I’d rather not have to muddy up my database for this.

I’m able to access and modify the retrieved data from the information provided in this thread:

I’m hoping there is an easy function I can call to insert a new column before the content gets inserted in the DOM.

ALSO - are there functions / methods we can call to fetch data that aren’t directly tied to a dynamic block? For example, if I wanted to populate a simple text field with a random entry In a table. or if I wasn’t happy with the current block options and wanted to whip up my own.

Hi @Jonathon and welcome to the community!

I apologize in advance that my answer is not going to be exactly what you are looking for.

Softr is really great at driving a web page off of data in Airtable. Any time you can take advantage of this fact, you’re working with Softr, and when you have to do things a different way, you’re fighting Softr.

I saw that you were concerned about muddying up the database, but I think this is one of those situations where muddying up the database is the lesser of two evils. Adding a formula that computes a different format of a value in another field is low overhead, and it’s easy to hide that formula field if it feels like clutter. Whereas adding custom code to the Softr app for this is going to be costly both in the present and in the future.

Additionally, while there is a JavaScript table component on the page that Softr uses to construct the table, its API is not available to custom code, so calling a function to insert a column on the page is theoretically possible, but Softr would have to expose that API to us. So right now it’s impossible, and even if we could do it, I’d advise against it in this scenario.

Could you say a little more about what your specific concerns are re: muddying up the database? Perhaps there are ways to address those concerns.

1 Like

Thanks for the response and I appreciate the viewpoint for working within the constraints of a tool.

I’m a Google AppSheet developer, so my usecase is with Google Sheets rather than Airtable. I understand there are differences between the two platforms both at their core and also in the maturity of their Softr integration. I’m not sure if those differences are relevant to this issue since they both use tabular data and this use-case is readonly.

My concern with muddying up the data is partly to accommodate high level AppSheet annoyances, but also for database normalization good practice.

I’m loving Softr for how its handling user authentication / roles. Unfortunately interacting with the dynamic blocks has felt quite restrictive, which is why I was hoping Softr did expose their component APIs, or allowed me to feed my own components with Softr fetching the data.

@Jonathon we do plan at some point opening up components for more customisation, however we are not there yet and currently as David mentioned doing it from data side would be the best possible option.

1 Like

Thanks @artur! Your post on event listeners for dynamic lists was great; is there documentation for other data/functions/APIs that are accessible to us?

Also, another concern of mine is the ID field softr creates for us. Is there an underlying requirement that Softr has to initialize this ID for us? My data already has unique fields, and the softr one is completely ignorant of the existing relational data model + relationships.

It would be better if we could select the identity column when adding the data block. Maybe an option for users to select their own and a “I don’t know what this is, make one for me” button to support the larger audience?

If the above isn’t possible, then at least let us name the column or change the default on your end. The column that Softr is adding is aweful. It has spaces :nauseated_face: and an emoji in it :face_vomiting:. I haven’t dug this deep yet, but I suspect I’m going to have to add special handlers to any cloud functions I have reading from these tables.

@Jonathon good comments on ID column let me take that into a team and see how we can improve. Thanks!

Re other functions I haven’t yet managed to write a proper documentation but sharing our internal drafts here

1 Like