How to pass argument to a server script function with client script?

Hi, I can access the script server, but not the function. and I would like to be able to call the function from frappe.call() and pass arguments.

I have the same doubt about the api, how can I access the function from the endpoint and pass it an argument.

try to use the same name of the method and function but it doesn’t work

I am using a frappe cloud instance

So I have it and without success. everything outside of the function works, the problem is that I can’t call the function from the client script


1 Like

Hi:

Don’t use def and return …
Just frappe.response["message"]="Hola amigo"

Hope this helps

I would like to pass the name value from the client script, how does it work without a function?

Using frappe.form_dict.get(‘user’, ’ '), I can receive the value sent as an argument from frappe.call in client script and condition that if I don’t receive a name, user is passed to " "

Hi:

Use frappe.request

datos = frappe.request.get_data()
frappe.msgprint(datos)
frappe.response["message"]=datos

Pass arguments from frappe.call

frappe.call({
    "method":"testapi",
    "args":{
        "arg1":"hola",
        "arg2":"adios"
    }
})

Hope this helps.

2 Likes

It works for me with both, thanks

1 Like

How to access the two arg value from frappe.request.get_data()?

Hi @rakesh_s:

Let’s say you have 2 args, arg1 and arg2

On server side:

server_side_arg1 = frappe.request.form.get("arg1")
server_side_arg2 = frappe.request.form.get("arg2")

Hope this helps.

1 Like