Reference from one form to another form

Hi,

Can anybody describe how to create reference from one form to another (e.g. I need Customer ID to print on Sales Invoice) ? Should I use DocType ?

Thanks in advance

hi @PeterWR
use this method
write this method in the custom script of sale Invoice
cur_frm.add_fetch(ā€˜customerā€™,ā€˜customer_idā€™,ā€˜customer_idā€™)
for more detail see this link Client side scripting Ā· webnotes/wnframework Wiki Ā· GitHub

I see, but still dosenā€™t work.
cur_frm.add_fetch(ā€˜customerā€™,ā€˜customer_idā€™,ā€˜customer_idā€™)

first field ā€˜customerā€™ according to your link, it is name of form from which I want to fetch data ?
second filed ā€˜customer_idā€™ - filed from which I will fetch data - source filed ?
third filed - it is target filed which I created in target form

I am new in ERPnext, please be patient.

Hi @PeterWR the first argument is the name of link field name of the field i.e.referencing Customer Form second is source field i.e field on Customer Form third one is target field i.e. field on Sales Invoice in your case .

Thank you for reply.

What type of field should be the field on target form, because source field is ā€˜dataā€™ type, so target field should be link or data type as source field ?

@PeterWR it should be of same type as source field

@PeterWR, @ravindra_l another approach without scriping is, create the target field as Data, turn it read only and put in options ā€œcustomer.customer_idā€, where customer is your link field and customer_id the field that contains the value that you are looking for!

It works ! Thanks !

If I want to make reference to some field in Sales Order, should I write: salesorder.my_filed or sales order.my_field ? Because both of references didnā€™t work.

@PeterWR {base_field}.{target_field}

Where base_field is the link fieldname in the active doctype and target_field is the field with the value in the related doctype, that are you looking for.

Dont forget of replace {base_field} and {target_field} for the property values.

1 Like