Skip to main content

Fetch Custom Field Value from Master to Transactions in Frappe (v15)

Introduction: Why Field Propagation Matters in ERP Systems

Data inconsistency is one of the most common problems in ERP implementations.
When master data changes but transactions continue to use outdated values, reporting accuracy and operational trust break down.

In Frappe Framework v15, this problem is solved cleanly by fetching custom field values directly from master DocTypes into all related transaction DocTypes.

What Does “Fetch Custom Field Value” Mean in Frappe?

Fetching a custom field means automatically pulling a value from a linked master DocType (such as Customer or Item) into a transaction DocType (such as Sales Order or Invoice) at runtime.
This is done using the Fetch From property in a field definition.

When Should You Use Fetch From?

Use fetch logic when:

  • A transaction must reflect master data at the time of creation
  • The value should be read-only in the transaction
  • Manual data entry must be avoided
  • Reporting consistency is critical

Technical Prerequisites

Before proceeding, ensure:

  • Developer Mode is enabled
  • You have System Manager access
  • You are working on Frappe Framework v15

The master DocType already contains the required custom field

Understanding the Core Concept

Master → Transaction Relationship

Example relationship:

Master DocType Transaction DocType
Customer Sales Order
Item Delivery Note
Supplier Purchase Invoice

The transaction must have a Link field pointing to the master.

Step-by-Step: Fetch Custom Field from Master DocType

Step 1: Create a Custom Field in the Master DocType

Example: Add a custom field in Customer

  • Field Name: customer_segment
  • Field Type: Data

This field stores the value you want to propagate.

Step 2: Identify the Link Field in the Transaction

Example: In Sales Order, the link field is:

customer

This field links Sales Order → Customer.

Step 3: Create a Custom Field in the Transaction DocType

Now create a custom field in Sales Order:

Property Value
Field Label Customer Segment
Field Name customer_segment
Field Type Data
Fetch From customer.customer_segment
Read Only ✔️ Enabled

How Fetch From Works Internally

<link_field>.<fieldname_in_master>

In this example:

customer.customer_segment

  • customer → Link field in Sales Order
  • customer_segment → Field in Customer

Frappe resolves this automatically during document load.

Does the Value Update Automatically?

Important behavior in Frappe v15:

  • Value is fetched when the document is loaded or refreshed
  • Existing submitted documents do not auto-update
  • New transactions always pull the latest master value

This ensures data integrity and audit safety.

Fetching Fields in Child Tables

Use Case: Item Attributes in Sales Order Items

Example:

  • Master: Item
  • Transaction Child Table: Sales Order Item

Fetch From syntax:

item_code.item_group

Configured inside the child table DocType.

Best Practices for Fetching Custom Fields

  • Always mark fetched fields as Read Only
  • Avoid fetch for values that must be editable
  • Use fetch for classification, category, region, tax group
  • Keep master data clean and validated

Common Mistakes to Avoid

Using incorrect field names
Fetching from non-Link fields
Expecting historical documents to auto-update
Using fetch where dynamic recalculation is needed

Troubleshooting Fetch Issues

Field Not Fetching?

Check:

  • Field name spelling
  • Link field exists and is populated
  • Master field is not hidden or permission-restricted

Value Not Updating After Master Change?

This is expected behavior.

Solution options:

  • Reload the document
  • Use a Custom Script for forced refresh
  • Use server-side logic for retroactive updates (advanced)

Advanced Use Case: Fetch vs Server-Side Sync

Property Value
Field Label Customer Segment
Field Name customer_segment
Field Type Data
Fetch From customer.customer_segment
Read Only ✔️ Enabled

Industry Relevance

This pattern is widely used in:

  • Manufacturing (Item classification)
  • Real estate (Property attributes)
  • Distribution (Customer category, region)
  • Finance (Tax group, ledger mapping)

Summary: Clean Data Flow with Fetch From

Fetching custom field values from master DocTypes ensures:

  • Zero manual duplication
  • Accurate reporting
  • Faster transaction entry
  • Strong data governance

In Frappe Framework v15, the Fetch From mechanism is the safest and most maintainable way to propagate master data across transactions.

Rating: 0 / 5 (0 votes)