I am having trouble fetching the value of a link field (custom) which i created on a page. What I want is whenever any value is selected in link field, I get that value on change.
I am having a .js and .py file for a page.
I am writing a sql query where the value selected in link field of page will go to my query in where condition But I’m having trouble in doing so. Here’s my code
js_file
frappe.pages['customer'].on_page_load = function(wrapper) {
var page = frappe.ui.make_app_page({
parent: wrapper,
title: 'Customer',
single_column: true
});
frappe.show_alert('Hey '+frappe.session.user,3)
page.custom_field = page.add_field({
fieldname: 'customer',
label: __('Customer'),
fieldtype: 'Link',
options: 'Customer',
});
frappe.breadcrumbs.add("CRM");
}
frappe.call({
method: 'customer.customer.page.customer.customer.details',
args: {},
callback:function(r){
console.log(r.message)
}
});
py_file
import frappe
@frappe.whitelist()
def details(name):
customer = frappe.db.sql("""select customer_name,lead_name,email_id,mobile_no,primary_address from `tabCustomer` where name = %s""",name)
return {'Customer Name':customer[0][0],'Lead Id':customer[0][1],'Email':customer[0][2],'Mobile':customer[0][3],'Address':customer[0][4]}
I want that the name of customer selected in page, when selected I get all the data of that customer,
Any suggestions ?