How does a field fetch data

Can anyone help me with this query
I want to know that let’s say we have a field named xyz
Now this field xyz is in item master and now i want this xyz field to fetch value in a child table so should we code for it i.e. item_code.xyz
Or should we declare in item master that field xyz is of type =data or text or date etc then declare same xyz type = link in customisation of child table

Not sure if I understand your question correctly, but if you have a field item.xyc and you would like to have this populated from a child table of Item, you will have to write a custom script that fetches the value and writes it into xyz (cur_frm.set_value("xyz", value);)

I will explain in detail i have two fields A and B in item master .A’s type = data and B’s type = data…Now i want A field in my sales invoice also n it should fetch value from item master and similarly I want B in my sales invoice item table and it should fetch value from item master …what should i code for A and B
Will there be type=Link used anywhere in above scenario?

This you can achieve in V12 using the “fetch_from” option, then specify <link_field>.<field_name>, i.e.

item_code.A

the type is data, preferably make it read-only. Refer to examples that use the same logic.

1 Like

you can see :

https://erpnext.com/docs/user/manual/en/customize-erpnext/custom-scripts

and

https://erpnext.com/docs/user/manual/en/customize-erpnext/custom-scripts/fetch-values-from-master

1 Like

What if i have to fetch manufacturing date and expiry date from Batch (doc) to item master
Label : Manufacturing Date
Option: Batch
Fetch from : item_code.manufacturing_date
Or should it be Batch_code.manufacturing_date ?
I am working in version 12

Use item_code.manufacturing_date and fetch into a Data field (not date)

1 Like

Do i interpret you correctly …
Manufacturing Date in item master should have type= data (not date )
And in fetch from in item master we should write item_code.manufacturing_date
Is it so ?

No, the field where the value is fetch to should be Data. The original field should be date if it is a data value…

Ok will try