In iVendNext, manually re-entering data across linked documents (e.g., copying Customer PO details from a Sales Order to a Sales Invoice) is time-consuming and error-prone. This guide explains how to automatically fetch data between documents using field mapping, scripts, and best practices to ensure accuracy and efficiency.
Automate data transfer in these scenarios:
Creating Sales Invoices from Sales Orders.
Pulling Terms & Conditions from a master document.
Syncing customer/vendor details across transactions.
If two documents have fields with the exact same name, iVendNext auto-populates the target field when creating a linked document.
Identify Source and Target Fields
Example: Fetch po_number from Sales Order to Sales Invoice.
Add Matching Fields (if missing):
Go to: Setup > Customize > Customize Form
Add the same field name (po_number) to both documents.
Test the Flow
Create a Sales Invoice from a Sales Order.
The po_number will auto-populate.
Note:
Field names must match exactly (case-sensitive).
Works for Text, Date, Link, and Number field types.
For fields that don’t match names (e.g., fetching a customer’s vat_id), use the add_fetch method in a Custom Script.
Add Fields to Both Documents:
Add vat_id (Text field) to Customer and Sales Invoice.
Create a Client Script:
// In Sales Invoice Custom Script
cur_frm.add_fetch('customer', 'vat_id', 'vat_id');
customer: Link field in Sales Invoice.
vat_id: Source field (Customer).
vat_id: Target field (Sales Invoice).
Save and Test:
Select a Customer in the Sales Invoice.
The vat_id will auto-fetch.
Display a complete address from a Link Field (e.g., Customer Address) in a read-only field.
Add Fields to the DocType:
A Link Field (address_link) pointing to Address.
A Read-Only Text Field (full_address).
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);
}
});
} else {
frm.set_value("full_address", "");
}
});
Save and Enable the Script:
The full_address field will update when an address is selected.
Pull pre-defined terms from a master document (e.g., "Contract Templates") into transactions.
Add a Link Field (terms_template) to your form.
Add a Read-Only Text Editor Field (terms).
Configure "Fetch From":
Set:
terms_template.terms
This maps the terms field from the linked template.
Test:
Select a template in the form.
Terms auto-populate.
Standardize Field Names: Use consistent naming (e.g., po_number everywhere).
Document Dependencies: Note which fields rely on scripts or linked masters.
Test Extensively: Validate with edge cases (e.g., blank fields).
Automating data fetching in iVendNext reduces manual entry, minimizes errors, and speeds up workflows. Whether using field matching, add_fetch, or custom scripts, choose the method that aligns with your document relationships.
✅ Field matching works for simple, same-name transfers.
✅ Use add_fetch for linked masters (e.g., customer VAT ID).
✅ Client scripts enable complex fetches (e.g., full addresses).