Reference from one form to another form


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
for more detail see this link Client side scripting · webnotes/wnframework Wiki · GitHub

I see, but still dosen’t work.

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