Custom Link Fields in ERPNext
Link fields in ERPNext are used to connect one DocType to another. For example, the Customer field in a Sales Order is a Link field connected to the Customer master.
You can create custom Link fields using the Customize Form feature.
Step 1: Go to Customize Form
Navigate to:
Home > Customization > Form Customize > Customize Form
Step 2: Select the DocType
In Customize Form, select the required DocType such as Quotation, Sales Order, or Purchase Invoice Item.
Then, in the fields table, choose the position where you want to insert the new field and click Insert Above.
Step 3: Configure the Custom Field
Set the following values for the new field:
- Label: The display name shown in the form
- Type: Link
- Name: Internal field name
- Options: The DocType to which this field should link
Adding Filters to Link Fields
From version 15 onwards, ERPNext provides a UI-based way to add filters to Link fields.
Each Link field includes an action icon that allows you to define filters for selecting records.
For example, in the Company field, clicking the icon opens a dialog where filters can be applied.
After applying filters, only matching records will be displayed in the Link field.
If filters are modified in Customize Form, a Reset to Default option appears to restore original settings. Note that filters defined in Customize Form override UI filters.
Eval-Based Dynamic Filters
ERPNext also supports dynamic filtering using eval: expressions.
Example usage:
eval: doc.fieldname
eval: doc.fieldname1 + doc.fieldname2
These expressions evaluate values dynamically from the form.
Child Table Filters
- From child table row:
doc.child_table_field_name - From parent document:
parent.parent_doc_fieldname
Note: Filters applied using
frm.set_querywill override UI-based filters.