Is it possible to use 'Server Script' without creating a custom app?

HI everyone, below is a doctype I have created. My question is how can I fetch the child table from the selected ‘Job Interview Template’?

Can I use ‘Server Script’ without creating a custom app? i.e. using @frappe.whitelist method in Server Script & Custom Script

It should work similarly to Appraisal Template.

  • picked from appraisal.js
  kra_template: function(frm) {
		frm.doc.goals = [];
			method: "",
			source_name: frm.doc.kra_template,
			frm: frm
  • picked from
def fetch_appraisal_template(source_name, target_doc=None):
	target_doc = get_mapped_doc("Appraisal Template", source_name, {
		"Appraisal Template": {
			"doctype": "Appraisal",
		"Appraisal Template Goal": {
			"doctype": "Appraisal Goal",
	}, target_doc)

	return target_doc

I believe there are still many users in the community like myself which have yet to fully understand this new feature, Server Script. Your guidance would be greatly appreciated. Thank you in advance. :grinning:

1 Like


I’ll answer the best I can:
Technically yes, everything is possible.
That being said, you’ll have a major issue when you will update/upgrade your frappe/erpnext version. You might loose every changes you made because all of those changes will be in frappe/erpnext folders. You could always merge your changes with theirs, but I don’t garentee it will work as you expected.

You could also write a custom script (js only) in ‘Custom Script’ Doctype. This code is in the DB instead of frappe/erpnext directory. The downside of this option, is that if something happen to your server (ex: bench migrate), you’ll loose that custom script. Which is quite a big downside honestly. To keep it, you need to add it to public/yourapp.js or add it in as a fixtures.

Is there a reason why you don’t want to create a custom app?
With a custom app, you’ll gain so much more freedom regarding those kind of changes.


I think that you can use the “API” form of the doctype “Server Script” to create the python whitelisted method. And the “Custom Script” doctype to create the JS part. They are not going to be deleted on a migrate. They work like every doctype, for example, the customers are not deleted in a migrate. You are going to lose it if you do a bench reinstall for example.


is it working right now with you ?

I’m trying this (putting the python code / query in the Server Script doctype of type API) but encountering the error AttributeError: module has no attribute 'whitelist' when I try to call the API method. I’ve added @frappe.whitelist() in the Server script.

Any clue what I might be doing wrong?