Fetching Data from Linked Masters

Fetching Data from Linked Masters

Overview

In iVendNext, linked masters (e.g., Customers, Items, Contracts) store centralized data that multiple documents reference. Manually re-entering this data wastes time and risks errors. This article explains how to auto-fetch information from linked masters into your transactions using field mapping, scripts, and best practices.




When to Use Linked Data Fetching

Automate data transfer for:
Customer/Vendor Details (e.g., VAT ID, Payment Terms).
Product Information (e.g., Description, UOM).
Standardized Templates (e.g., Terms & Conditions).




Method 1: Field Name Matching

How It Works

If a Link Field (e.g., customer) points to a master, and both documents share fields with the same name, iVendNext auto-populates the data.


Step-by-Step Setup

  1. Add Matching Fields:

    • In your document (e.g., Sales Invoice), add fields with names identical to the master (e.g., vat_id).


  1. Create the Link:

    • Ensure your document has a Link Field (e.g., customer) pointing to the master (e.g., Customer).


  1. Test:

    • Select a Customer → vat_id auto-fills.


Note:

  • Field names must match exactly (e.g., vat_idvat_number).

  • Works for Text, Date, Check, and Number fields.




Method 2: Using add_fetch for Non-Matching Fields

When to Use

If field names differ between documents (e.g., master uses tax_id, but your form uses vat_number), use the add_fetch method.


Script Example

// In Sales Invoice Custom Script  

cur_frm.add_fetch('customer', 'tax_id', 'vat_number');  


  • customer: Link Field in your document.

  • tax_id: Source field in the Customer master.

  • vat_number: Target field in your document.


Result: Selecting a Customer auto-populates vat_number from their tax_id.




Method 3: Fetching Full Addresses

Step-by-Step

  1. Add Fields to Your DocType:

    • A Link Field (address_link) pointing to Address.

    • A Read-Only Text Field (full_address).


  1. Add a Client Script:


ivendnext.ui.form.on("Sales Invoice", "address_link", function(frm) {  

  if (frm.doc.address_link) {  

    frm.call({  

      method: "ivendnexterp.contacts.doctype.address.address.get_address_display",  

      args: { "address_dict": frm.doc.address_link },  

      callback: function(r) {  

        if (r.message) frm.set_value("full_address", r.message);  

      }  

    });  

  }  

});  


  1. Test:

    • Select an address → full_address displays the complete text.




Method 4: Pulling Terms & Conditions

Scenario

Auto-fetch pre-approved terms from a Contract Template into a Sales Order.


Setup

  1. Add Fields:

    • A Link Field (contract_template) pointing to Contract.

    • A Read-Only Text Editor (terms).


  1. Configure "Fetch From":

    • In terms field properties, set:


contract_template.terms  


  1. Test:

    • Select a Contract Template → terms auto-populates.




Troubleshooting

Here’s a quick look at some common issues you might run into.


Issue

Solution

Data not fetching

Verify field names match exactly (case-sensitive).

Script errors

Check browser console for typos in method names.

Blank values

Ensure the master document has data in the source field.




Important Points To Remember

Some of the key points to remember are:


  1. Standardize Field Names: Use consistent names (e.g., vat_id across all docs).

  2. Document Dependencies: Note which fields rely on linked masters.

  3. Validate Permissions: Ensure users can read the master data.




    • Related Articles

    • Customizing Data Flow with Linked Masters

      Overview This article gives you an overview of how iVendNext's Linked Masters feature streamlines data flow between related documents. 1. Understanding Linked Masters Core Concepts Master Data: Authoritative source records (Items, Customers, ...
    • Fetching Data Across Documents - A Step-by-Step Guide

      Overview Avoid manual data entry in iVendNext. Instead of copying details between documents, use field mapping and scripts to auto-fill data accurately. This guide shows you how. You can add Custom Fields using the Customize Form feature in ...
    • Working with Query Reports - Fetching Data Directly from the Database

      Overview Query Reports in iVendNext let advanced users pull data using SQL for detailed, custom reporting. Unlike the no-code Report Builder, they offer full control over data queries—ideal for complex needs. However, cloud users can't write SQL ...
    • Fetching Data from Child Tables Using Jinja Tags

      Overview Child tables in iVendNext (e.g., Items, Taxes, or Additional Costs) store multi-row data linked to a parent document (e.g., Sales Invoice or Purchase Order). While Report Builder displays child table rows as duplicate lines, Jinja templating ...
    • Customizing and Managing Data

      Overview This article will guide you through the key features and best practices for customizing and managing data in iVendNext. 1. Introduction to Data Customization and Management in iVendNext iVendNext offers a range of tools that allow you to ...