Changing the Options for Field Type : Links


Customizing options in the Doctype Link field

I have a field “Meeting Type” Type: Select, Options: Internal/External
A Child Table - Column 1 - “Name” Type: Link Option: Employee/Contact
Column 2 - Comment

When I Select Internal from dropdown list in , I want to show “Employee” list in Child Table’s Name field, and “Contacts” list when I select External.

Is It possible? If Yes then please guide.

Hi @umarless,

Please check the process.

Parent DocType Field:

Child DocType Field:

Client script:

frappe.ui.form.on('Test DocType', {
	type: function(frm) {
	    var row = frm.add_child('test_child_table');
	    if (frm.doc.type == "Internal") {
    	    row.for = "Employee";
	    } else {
	        row.for = "Contact";

frappe.ui.form.on('Test Child Table', {
	test_child_table_add: function(frm, cdt, cdn) {
		var row = locals[cdt][cdn];
		if (frm.doc.type == "Internal") {
		    frappe.model.set_value(cdt, cdn, 'for', "Employee");
		} else {
		    frappe.model.set_value(cdt, cdn, 'for', "Contact");

Please set your field name and doctype name.

Then reload (Ctrl + Shift + R) and check it.


When you select Internal Type then Employee will show in the doc name field and when you select the External Type then Contact will show in the doc name field.

I hope this helps.
Thank You!


Thanks a lot for your solutio Mr. Patel.
There is a small issue in script.
When I am selecting Type: Internal/External, New Row in Child table is getting inserted with the respective doctype Employee/Contacts.
Whenever I am clicking on “Add Row” button It’s inserting empty row.

May I fix that “Add Row” option that Whenever I click on “Add Row” button new row with default value: Employee/Contact in “For” field should be inserted?

Yes, you can.
Please customize your according.

Thank You!


Hi Nihantra,

Thanks a lot for giving reply/solution to my all queries.

Now If I want to get fetch Company and Designation to next column in same table of selected employee/contact then how can I do it?

After selecting name form employee master, company and designation should be auto fetched.

As well As please guide me where I can learn all basics and advance of Client Script / Form Script.


That for, add condition in fetch from like
In company field for use:

In designation field for use:



I hope this helps.
Thank You!

1 Like


I tried above resolution but not worked.

Here are screenshot for your reference.

As per your previous guidance I made this table.

Now, when I select employee/Contact name in “Name” field.

It’s not fetching company name and designation.

Please check it.


1 Like

Thats why I am little confused. :slightly_smiling_face:

Field “Fetch From” is empty dropdown.

After Selecting Field Type “Link” in previous Field, “Fetch From” getting previous Field “Doctype”

Hello @NCP,

Request to update on this?

Is It because of difference in version?

ERPNext: v14.x.x-develop () (develop)
Frappe Framework: v15.x.x-develop () (develop)

how can we achieve this when there is no fetch from field?

It does not work on the doctype level.
It works only on customize form level.

1 Like

Hello @NCP

How can I fetch Employee’s Company name, when I select a Employee.

Please guide on this, give some hint.

That for use client script.

1 Like

Hello Community,


Here is the same issue with doctype “Event”, which has a child table “Event Participants”.

In child table when we select “Reference Document Type” (filter applied for Contact and Employee with your help) as Contact/Email, Next Field in Child Table gets all Contact and Employee List.

Now, after selecting contact/employee name in field “Reference Name”, Email Id should be fetch automatically, Here is the screenshot of Script which is not working.

Filter Applied for doctype.

Script for fetching email for contact or employee

Hi @falahtech,

fetch employee for:

Note: Next time, Please create a new thread for the new issue.

Thank You!