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"

script_2 (api):


…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?

Hi @peterg

Trust you’re doing great. Were you able to work this out ? If so, pls share how

Also, I’d really appreciate if you could share any sample(s) of working API Server Scripts


Hi there,
This wasn’t possible last year, but I believe it might be now. As of the latest v13 release, has been added the Script API safe execution roster. I haven’t had a chance to play with it yet, but I suspect it should work.

1 Like

Great! Any sample API script you can share ?

Nope, like I said, I haven’t had a chance to play with it yet.

Oh, sorry… thot you were referring specifically to calling the API script from another server script

Many thanks

Oh, yeah, I was talking about that. For regular api server scripts, we have dozens going on our company’s server. Most are pretty specialized to internal processes and integrations, so I’m not sure much would be useful to share, but if you have any questions feel free to make a thread and tag me.

1 Like