Suppose I have a DocType in Frappe which has many fields. One of the fields (say a dropdown or a data table) needs data from a database of another application, which is not Frappe based.
I read from the forums that we can periodically sync data from external system into Frappe using REST APIs. But I do not want data synchronization, but rather keep the two systems independent and maintain a “foreign key” kind of link from Frappe to the external system’s database.
So, how do I bring data from an external system’s database into Frappe Form?
How do I achieve this?
Frappe doesn’t have true computed fields, but you can set up triggers to update fields at relevant moments. The best approach here will depend largely on how that data is accessed and whether or not it’s used by other doctypes. If it’s just a matter of pulling external data into a form view, you can do this with custom scripts relatively easily. It’s just a matter of pulling data from your external api on refresh or save, as makes most sense per your needs.
but you can set up triggers to update fields at relevant moments
Can you please elaborate on this a bit more as I am not clear on how I would use a Trigger.
The best approach here will depend largely on how that data is accessed and whether or not it’s used by other doctypes
The external data will be used by multiple DocTypes in Frappe. One such simple example is to access the list of Vendors maintained in an external system and show it as a dropdown in a Frappe DocType field. And when the form data gets saved in Frappe, the Vendor Identifier should also be saved in Frappe as part of the document. And later, wherever this saved document is displayed in Frappe, corresponding Vendor details (such as Vendor Name) for the saved Vendor Identifier should be retrieved from the external system and displayed in Frappe.
Are you familiar with Form Scripts? You can create these right in your Frappe installation without any access to the server by going to
Custom Scripts in the search bar.
Note this will only be useful when interacting with documents via forms. Custom scripts don’t trigger if, for example, you access a document via report or api.