Try ERPNext Try Frappe Cloud Buy Support Partners Foundation

Call Server Script from another Server Script?

I’ve defined a new API-type Server Script used to update custom fields in the Issue doctype. I’d like to be able to call this script from various DocType-event-type Server Scripts. Is this possible?

I’ve tried playing around with the run_script method, but I can’t seem to pass parameters. Is there another way?

Any ideas or suggestions out there?

use frappe.flags. The safe_exec environment maintains its own set of flags.

Thanks Rushabh! That makes a lot of sense. I saw reference to flags in the documentation, but I’m realizing now that I misunderstood how they worked. This works perfectly.

Actually, I’m still failing to get this to work. I’m able to use flags to return values, but not to send values.

script_1 (doc event):

frappe.flags.my_key = "test flag"
run_script('script_2')

script_2 (api):

frappe.msgprint(frappe.flags.my_key)

…isn’t working for me. Am I misunderstanding?

Anyone know if this is possible?

I’m still trying to understand if I’m just not doing something correctly or if this functionality is not available.

Is it possible to send parameters or flags from one custom script to another?