Call Server Script from another Server Script?

to get the response back set the below
frappe.flags.message = l_response inside the server script api

The flow goes like this

define a server script api say ‘my_api_server_script’

let’s assume the above script takes two arguments arg 1 and arg2

to fetch the args inside the api script

arg1 = frappe.form_dict.get('arg1') 
arg1 = frappe.form_dict.get('arg2')

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

response = frappe.call("my_api_server_script", arg1 = value1, arg2 = value2)
result = response["message"]

Hope this helps

3 Likes