Set Value Into Child table field

thanks for your kind reply…yes “Implement Plan” is the child doctype name

What is the main doctype name?

Main Doctype Name: Implementation Plan
Child Doctype Name: Implement Plan
Child Table Name: Plan
Child Table Field Name: tcd
Thanks In Advance

Ha, sorry I mixed up both names.

Change this to

frappe.ui.form.on(“Implementation Plan”, “validate”, function (frm, cdt, cdn) {

see if it triggers on save?

I changed and i tried but problem is i could not able to save…

Ok no need of validate method. Also try to check your date format is correct, hard code date first to see it it works?

function get_today_date(numb) {
                    var d = new Date();
                    var result = d.setDate(d.getDate() + (Number(numb)));
                    console.log(result);
                    return new Date(parseInt(result));
 };

frappe.ui.form.on("Implement Plan", "tcd", function(frm, cdt, cdn) {
                    frm.doc.tcd = get_today_date(30);
                    console.log(frm.doc.tcd);
                    cur_frm.refresh_field("plan");

});

I think you better set “tcd” on setting of any other mandatory field in the child doc.

Hi Again,
I am keep trying what you said but no change from UI even console msg is also not getting printed…

This should definitely work, :slightly_smiling_face:

function get_today_date(numb) {
    var d = new Date();
    var result = d.setDate(d.getDate() + (Number(numb)));
    return new Date(parseInt(result));
 };

frappe.ui.form.on("Implement Plan", "other_child_docField", function(frm, cdt, cdn) {
    var child = locals[cdt][cdn];
    child.tcd = get_today_date(30);
    cur_frm.refresh_field("plan");
});
6 Likes

Thank You So Much…

i just add before this function plan_add: function(frm,cdt,cdn) now it set into childtable field.

ok great :+1: