Trying to Invoke Server Script API throws "App [method] is not installed"

I defined a Server Script API Method using the Server Script doctype. I called the method “my_test_method”.

I wrote a Client Script that creates a MultiSelectDialog and uses the “query” attribute to invoke “my_test_method”. Unfortunately, when I try to use it, I get the error:
“App my_test_method is not installed”

Yeah that makes sense because the method is a Server Script method – its not really part of any module/app. Is there a default module to which all Server Script methods get assigned?

I tried “core” but that doesn’t work.
I tried “frappe” but that throws this error instead:

AttributeError: module ‘frappe’ has no attribute ‘get_expense_claims_having_non_invoiced_pass_through_expenses’

Bumping this. New approach to the issue:

In frappe init.py, there is a get__attr() method that gets invoked from frappe.call().
The code starts with:

def get_attr(method_string):
    """Get python method object from its name."""
    app_name = method_string.split(".")[0]

It presumes that you are invoking a method by prefixing it with its module name. However API Server Scripts don’t belong to a module. So how can you invoke them?

With frappe.call(), you just use the bare API method name. There’s no namespace.


image

I have no idea how/if this works for the query parameter for MultiSelectDialog. It’s very possible that those don’t have the capacity to call Server Scripts.

Edit: Sorry, just realized you’d deleted the message I was responding to. I’ll leave my response here for now in case it’s helpful.

Edit2: Also realized you were talking about the python frappe.call method. I don’t believe it’s possible to call server scripts that way.

Thanks Peter,

Indeed I had to delete my message because I realized it was very misleading.

The issue is that the MultiSelectDialog “query” parameter passes the query parameter to the server and then the server python code uses python frappe.call to invoke the method. This blows up because it expects a module!

This looks like it could be considered a design flaw or bug. Unless not allowing use of API Server Script from MultiSelectDialog is intentional?

I doubt it was intentional. Server Scripts are a relatively recent addition to Frappe, and they have a very different execution process than the one used by queries. I suspect it just has never been added as a possibility to MultiSelectDialogs. Link queries in general are probably due for a refactor at some point.

This seems to work to call a server script from a python method inside my app

frappe.api.v2.handle_rpc_call(api_server_script_method_name)

if you want to call a method of DocType class use this

frappe.api.v2.handle_rpc_call(method_name,doctypename)

Anyone know a reason why this should not be used?