Hey guys how can i populate contact phone field automatically when the contact is selected while on the HD Ticket page. Here’s the code i used on client script;
frappe.ui.form.on(‘HD Ticket’, {
contact: function(frm) {
if(frm.doc.contact) {
frappe.call({
method: ‘frappe.client.get’,
args: {
doctype: ‘Contact’,
name: frm.doc.contact
},
callback: function(response) {
if(response.message) {
var contact = response.message;
var phoneNumber = contact.phone || contact.mobile_no || ‘’;
frm.set_value(‘phone’, phoneNumber);
if (phoneNumber) {
frappe.show_alert({message: ‘Phone number updated’, indicator: ‘green’});
} else {
frappe.show_alert({message: ‘No phone number found for this contact’, indicator: ‘orange’});
}
}
}
});
}
}
});
This error suggests that there is no such field as “Phone” in your doctype. If this is a custom field, then the name will be something like custom_phone because there is no such field as “Phone” in the HD Ticket Doctype by default.