In Frappe, I’m creating custom scripts (client or server) for each doctype. However, I want to implement a remote lookup field with the flexibility to specify the URL, method, headers, etc., and fetch specific fields from the response.
bascially
I want to implement a customizable remote lookup field in Frappe, allowing specification of URL, method, headers, etc., and fetching specific fields from the response.
Can we call the server side script directly without specifying it in the doctype/api.py ?
basically,
can I implement this in client side script where fetch_states is the server-script on doctype core user without having to each time whitelist the method and trigger directly.
frappe.call({
method: 'frappe.core.doctype.server_script.fetch_states',
callback: function(response) {
var states = response.message;
// Set the options for the `user_state` select field
frm.set_df_property("user_state", "options", states);
}
});
I think, No, you cannot directly implement this in a client-side script where fetch_states is a server script on the doctype core user without having to whitelist the method each time. You must explicitly whitelist server-side functions to make them accessible from client-side scripts.
@NCP as per your first answer, its again dependent on the server and client-side scripts. Is there any generic remote lookup component available now/in future for use.
Also, can I use the custom-field to accomplish the above task(s) ?