I am trying to use the new options for server script in version 12.
I do not want to modify the .py files.
here is my code:
Python Server script:
Script Type: API
API Method: Print
Script:
def Print(m):
“console.log(m)”
frappe.response[‘message’] = m
JS Client Script:
frappe.call({
method: “Print”,
args: {
m : “test”
},
callback: (r)=> {
var m2 = r.message;
console.log(m2);
m2 = m2.toString();
frappe.msgprint(m2);
}
});
I get undefined in the console!.
Any suggestions pls.
I’m having a hard time reading your code because it’s not formatted (try using code fences ```), but did you see the instructions on the Server Script page?
# respond to API
if frappe.form_dict.message == "ping":
frappe.response['message'] = "pong"
else:
frappe.response['message'] = "ok"
API call args are available in the frappe.form_dict variable.