Custom Script for Fetching Values From Master - Dynamic Link

Hello,

I want to fetch email Id of Contact/Employee selected in a Dynamic Link Field in ChildTable “Event Participants” inside Parent Doctype “Event”.

I tried below script but Its not working.

Hi @falahtech,

I think you should check it.
Your scenario and documentation scenario is a little bit similar.
->: Example showing how to fetch value in a child table field from Master DocType

Thank You!

1 Like

Hi @falahtech,

Replied to this post.

frappe.ui.form.on('Event Participants', {
	reference_docname: function(frm, cdt, cdn) {
	    var d = locals[cdt][cdn];
	    if (d.reference_doctype == "Contact") {
    	    frappe.db.get_value("Contact", {"name": d.reference_docname}, "email_id", function(value) {
                d.email = value.email_id;
            });
	    } else if (d.reference_doctype == "Employee") {
	        frappe.db.get_value("Employee", {"name": d.reference_docname}, "personal_email", function(value) {
                d.email = value.personal_email;
            });
	    }
	}
});

Please set/check your field according to.
I think your problem will solve.

Thank You!

1 Like