Invoke custom function upon saving record

Hi all,

First of all, you have created an awesome product.

With regards to creating an object, I have a question wheter it is possible to invoke a custom function upon saving.

I know in Django, it is possible to overwrite the save method. But I was wondering how to achieve this in baserow, given the models are created dynamically.

(See e.g. Overriding the save method - Django Models - GeeksforGeeks)

In Django I use this for example to invoke a custom function, to translate adress to lat/lon and store these values.

It might also be, that I run a script and need to store the values in a different table (e.g. calculate a route with above values).

I was tinkering with baserow, and in the specific case of these lat/lon I can imagine a custom field or function could do the trick.

In essence, my question is what would be the best approach to invoke a custom function after saving an entry (and populate other fields, or even create an entry in an other table)?

Hi,

It depends on your case. If you want to calculate a link to a map based on a lat/long pair, you can do this with a formula field. For example:

link(concat('https://www.openstreetmap.org/#map=14/', field('Latitude'),'/',field('Longitude')))

In more complex scenario’s where you want to add rows in other tables based on certain input values, I would recommend using an automation service. There are some good tutorials on how you can integrate with n8n, Zapier or Make.

Regards
Frederik

No, basically I want to trigger a function.

In this example, pass street/city/country to a function, which returns the lat/lon, allowing Django to save them in the respective columns.

@Berik we offer the ability for technical users to make plugins which would let you do exactly this. I made an example geo spatial plugin that enables PostGIS and adds a “Point (lat/lng)” field type to Baserow last year which can be seen here: Nigel Gott / baserow_geo_plugin · GitLab which might be a good starting point. Our plugin docs are here: https://baserow.io/docs/plugins%2Fintroduction/ .

2 Likes

Thanks. Ill try to install that one and go from there.

@Berik FYI that is an example plugin that hasn’t been updated for a year, it might work out of the box, it might need fixing up first. The implementation was also very bare bones just to show how it could work.

Thanks. Ill just play around with it a bit, and with plugins in general.

I’m reasonably proficient with Django, so just need to get (really) familiar with baserow.

Have different ideas in mind I would like to tackle with baserow, given I like the concept of the dynamic models very much, as well as the integrated django-rest availability.

Though what I need from baserow is quite different from it’s intend, I think it suits my needs for a great deal. And I understand it its a no-code platform, I think being able to run custom functions against the data would be of great value (but as data-scientist / business analyst at an s&p 500 my requirements might differ from most).

hi @Berik , I am the co-founder of Baserow. I would love to have a conversation with you about your specific use case to understand it better. Would you be open for a chat ? You can reach me on olivier@baserow.io.