I need autopopulate in contact doctype when creating new contact from Issue doctype

Hi All,
i need in Ticket(Issue) doctype if create new contact in fieldname “custom_raised_by_email_id” field label “Raised by Contact Person” it should autopopulate in contact doctype "links"childtable for the fields “link_doctype”, "link_name"and “link_title”
and also customer link is having in ticket (issue) doctype by that we need autopopulate



Thanks in Advance

Hi @satyamsathya978,

You have to add client script for achieving your requirement,

Go to the Client Script => Create New
Doctype: Customer
Enable: 1

frappe.ui.form.on('Contact', {
	refresh: function (frm) {
	const last_doc = frappe.contacts.get_last_doc(frm);
	if(last_doc.doctype == "Issue" && frappe.db.exists(last_doc.doctype, last_doc.doctname)){
		frappe.db.get_value(last_doc.doctype, last_doc.docname, "customer", (r) => {
			frm.set_value("links", "");
			frm.add_child("links", {
				link_doctype: "Customer",
				link_name: r.customer,
			});
		})
	}
}
})

Add this code into script and save it, then links will be filled automatically whenever you create new contact from Issue (Ticket)

2 Likes