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?
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.
Hi there,
This wasn’t possible last year, but I believe it might be now. As of the latest v13 release, frappe.call 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.
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.
perform rest of code
finally send the result in frappe.flags
#to get the response from the server side
frappe.flags.message = result
#if you want to use the script from the client side
frappe.response["message"] = result
now you can call the api script from another server script like below