I have added some data to student batch student child table from student applicant doctype and then loaded student batch i am getting nothing in child table when i load the page but when i reload i was able to see data that i added
and i have done
cur_frm.refresh_field('students');
in student batch.js on onload function but i am not able to get any data on onload but if i refresh i was able to get data
can any please help me with this please
code that i used to add data to child table is
@frappe.whitelist()
def add_to_student_batch(name_of_student,id_of_student,parent):
doc = frappe.get_doc({
"doctype":"Student Batch Student",
"parent":parent,
"parenttype":"Student Batch",
"parentfield":"students",
"student_name":name_of_student,
"student":id_of_student
})
if(doc.insert()):
return "success"
@shahid_ecit,
Can you share the custom script which is calling add_to_student_batch
method
@makarand_b
var selectStudentIdFromStudentDocType = function(){
frappe.call({
method: "erpnext.schools.doctype.student_applicant.student_applicant.get_name_if_enrolled_empty_if_not",
args: {
name_of_student: JSON.stringify(getIdsFromList())
},
callback: function(r){
if(!r.exec)
{
stud_id = [];
stud_name = [];
x = 0;
res = JSON.parse(r.message);
var no_of_res = JSON.parse(r.message).length;
for (i=0;i<no_of_res;i++){
// checks and counts selected students who are not enrolled
if(res[i].length == 0){
x = x+1;
}else{
stud_id.push(res[i][0].name);
stud_name.push(res[i][0].title);
}
}
if(x>0){
frappe.throw("Please Enroll the Selected Student Applicants before adding to a Batch");
}
frappe.model.with_doctype("Student Batch", function() {
var tlb = frappe.model.get_doc("Student Batch");
$.each(stud_id, function(i, d) {
var detail = frappe.model.get_new_doc("Student Batch Student", tlb,
"students");
addStudentDetails(d,stud_name[i]);
$.extend(detail, {
"student": d,
"student_name": stud_name[i],
});
});
frappe.set_route("Form", "Student Batch/App Builder-abcd-2017-18");
})
}
}
});
};
and definition of
var addStudentDetails = function(stdId,stdName){
frappe.call({
method: "erpnext.schools.doctype.student_applicant.student_applicant.add_to_student_batch",
args:{
name_of_student:stdName,
id_of_student:stdId,
parent:"App Builder-abcd-2017-18"
},
callback: function(r){}
});
@vivin_joseph it not working
@makarand_b is there any hope on this please help