How open doctype and fill child table

I have js file student_applicant_list.js file

in that i added a code

$.extend(frappe.listview_settings[‘Student Applicant’], {
onload: function(listview) {
// adds new menu item to the menu button(blue colored)
listview.page.add_menu_item(__(“Add To Student Batch”), function() {
});
}
});

so i have this

my requirement is

when select a set of student and click Add To Student Batch field The student batch field’s child table should be prefilled

can anyone please help how can i do this

Hi @shahid_ecit

You can refer the below code

1 Like

@rohit_w thanks for the replay

but

i am not getting values in child table of student batch

what i have tried is

frappe.model.with_doctype(“Student Batch”, function() {
var tlb = frappe.model.get_new_doc(“Student Batch”);
$.each(selected, function(i, d) {
var detail = frappe.model.get_new_doc(“Student Batch Student”, tlb,
“student_applicant”);

$.extend(detail, {
“student”: d.name,
“student_name”: d.activity_type,
});
})
frappe.set_route(“Form”, “Student Batch”,“New Student Batch”);
})

where student applicant is source applicant

student batch is target doctype

student batch student is child table in target doctype

please help me to find what am i doing wrong

frappe.set_route(“Form”, “Student Batch”,tlb.name);

@rohit_w I have tried this but no change and i can’t find doctype time_log in erpnext

Yes, the code is for your reference only[quote=“shahid_ecit, post:3, topic:24641”]
“student”: d.name, “student_name”: d.activity_type,
[/quote]

Instead of d.name and d.activity_type, add hardcoded values and check

I hope child name is correct(student_applicant)

@rohit_w student_applicant is not child name it is source doctype

var detail = frappe.model.get_new_doc(“Student Batch Student”, tlb, “student_applicant”);
Add child table name instead of student_applicant

Child table name you can get from the doctype, for example sales order item doctype in sales order has name “items”

2 Likes

@rohit_w after i changed the student_applicant to student it is working beautifully as i expected

thanks a lot

you saved me a lot of time

thanks again for you support and providing you support and valuable information