Formula field?

Is there a way to create some sort of Formula field in DatoCMS? For example, if we are row of orders for a specific SKU: ABC. Can we create a row that sums these values? Sort of like a computed/generated column in postgres?

Hello @osseonews

Sure, it is possible to do this with some plugins, there is this one that computes the value of a field based on other fields: Computed Fields - Plugins - DatoCMS

thanks. I saw that plugin, but it seems to only work with fields from the current table, so it wouldn’t help if you need to create functions based on values from other tables. Actually, what we are trying to do is to keep track of inventory data in DatoCms, or understand if something like this is possible. I know we can do this by hitting a webhook, every time an order comes in, and then update an inventory table in Dato, but this seems like a hack of sorts to have to run a webhook function every time. So I was thinking maybe we have an inventory table that looks up the items in an orders table and then sums the total of specific items to get the proper inventory. So for example, if there are 10 orders of item ABC in the orders table, then the sum would be 10 and the inventory for ABC in the inventory table, would be reduced by 10. Does this make sense? Is this possible to achieve?

@osseonews , for product inventory i think that a better fit would be a database, not a CMS.

Although it can be done: You could create a custom plugin that reads the table and updates the other record by using the CMA (you can create a CMA instance through a plugin), it would probably be easier to achieve with the webhook solution, as the “webhook call” you would be saving, would be turned into the reading of the table and update the sum accordingly, and we don’t count webhook calls as we do API calls, so you can in theory have unlimited webhook triggers.

But, once again, its generally not a good idea to keep inventory through the CMS, and its more advisable to use a database solution for that.