I have requirement which is when i click a link i want to open a instance of doc-type which i created before
and fill it child table with given data. to make it clear i will produce an example
i have added 4 batches in student batch doc type
https://discuss.frappe.io/uploads/default/original/2X/f/f555b8ed6329e13c512df7f567b090a336682525.png
and i have other doc-type student applicant with list of students
when i select list of students i want to add selected students to student batch App Builder-TEST BATCH-2015-16
and fill the child table with selected student details.
i have already done adding student details to new instance of student batch
with help of @rohit_w
but my new requirement is add to existing student batch
i have tried some thing but i found no help with that i will share what i tried below
frappe.model.with_doctype("Student Batch", function() {
var tlb = frappe.model.get_doc("Student Batch Student");
console.log(tlb);
$.each(stud_id, function(i, d) {
var detail = frappe.model.get_doc("Student Batch Student", tlb,
"students");
$.extend(detail, {
"student": d,
"student_name": stud_name[i],
});
})
frappe.set_route("Form", "Student Batch/App Builder-TEST BATCH-2015-16",);
})
Above code opens student batch App Builder-TEST BATCH-2015-16 but no thing is added to child table
but when changed above code to
frappe.model.with_doctype("Student Batch", function() {
var tlb = frappe.model.get_doc("Student Batch Student");
console.log(tlb);
$.each(stud_id, function(i, d) {
var detail = frappe.model.get_doc("Student Batch Student", tlb,
"students");
$.extend(detail, {
"student": d,
"student_name": stud_name[i],
});
})
frappe.set_route("Form", "Student Batch/App Builder-TEST BATCH-2015-16",tlb.name);
})
i am getting an error in console
VM311:127 Uncaught TypeError: Cannot read property ‘name’ of null(…)
can an one please help me