Can Server Scripts be used for reports?

Hi ,

Is it possible to use Server Scripts for building reports? I would think this should be one of the major use cases for having the feature at all but don’t seem to find any article or discussion describing such usage

If anyone could give some insight or helpful links, it’d be much appreciated

Thanks

1 Like

Take a look at:
https://frappeframework.com/docs/user/en/guides/reports-and-printing/how-to-make-script-reports

Yes but with limitations, you cannot access frappe.db.sql

You can. I have script reports which can access db. Maybe they removed it in the latest version.

You can not use the frappe.db.sql() function, it will throw error. Try it

I believe its for security reasons

Still working fine for me in v12.

Can you pastebin your source codeif you were able to set up the filters please share the Javascript code

def get_employee_doj_map():
	return	frappe._dict(frappe.db.sql("""
				SELECT
					employee,
					date_of_joining
				FROM `tabEmployee`
				"""))

Works fine for me.
And filters, its normal default ones. I haven’t modified.

Thank you. I’ll try it. I tried writing the Javascript filters but no success. Same filters I successfully used in the JS files. It doesn’t work if I write script report from desk ui

Hi @rtdany10

Thanks a lot for your response. I’m not sure we’re on the same page though… I’m referring to Server Scripts which are created from the UI https://docs.erpnext.com/docs/user/manual/en/customize-erpnext/server-script

Could you confirm if this is what you used for your report?

Hi @mymi14s

How do you set the module and also how do you handle the js ?

Kind regards