Auto fill field value on quick entry

When we create new batch no on e.g. stock entry, purchase receipt…, user need to re-select item code on quick entry form. How to auto-fill item_code on batch quick entry form?

Any example that we can start with?


This doesn’t work…Any example?

frappe.ui.form.on("Purchase Invoice Item", {
	refresh: function(frm, cdt, cdn) {
		frm.fields_dict['items'].grid.get_field('batch_no').new_doc = function(frm, cdt, cdn){
			var d = locals[cdt][cdn];
			frappe.new_doc("Batch", {"item":d.item_code});

As suggested in another reply this is not configurable for now. Git issue exists for the same. Please refer and add you use case on the github issue created.

Hope this helps.

@ArundhatiS thanks for response. I think we can do it via custom script? Any example?

I had a similiar requirement… Here is my custom script…

1 Like

@Basawaraj_Savalagi it doesn’t work…

frappe.ui.form.on("Purchase Invoice", "refresh", function(frm) {
	frm.fields_dict['items'].grid.get_field('batch_no').new_doc = quick_entry_batch;

quick_entry_batch = function(doc, cdt, cdn){
	var d = locals[cdt][cdn];
	frappe._from_link = this;

not working…it’s not even triggered

Copy paste this whole code in custom script of purchase invoice

@Basawaraj_Savalagi not working…it’s not triggered

hello Basawaraj_Savalagi,

same enhancement i am doning but not able to reached the ans
i use below code

frappe.ui.form.on(‘Purchase Receipt’,‘onload’,function(frm){
cur_frm.field_dict[‘item’].get_query = function(doc,cdt,cdn){

Can anyone help me for the same


Hello Basawaraj_Savalagi,

I use your script it will working for me but when i select multiple item in the purchase receipt and then i will create a new batch for the particular item then it will apply only first item means item[0],if i select the second item then it will also take the first item while creating the new batch so how this fix can u please help for the same.


hey guys, i want the first_name and last_name field of health practitioner to be autofilled in quick entry employee form ? please reply as soon as possible

Any solution