Add 3 rows to child table and set value of row’s field

how can i fixing 3 rows in the child table

job title dept Target
hr manager HR
sales manager. Sales
marketing manager. Marketing

the department field must link with department doctype
and i will fill manually target field in the table

Hi @Osk,

Please check the client script syntax and apply it according to the scenario.

frappe.ui.form.on('Your Parent DocType', {
    onload: function(frm) {
        const rows = [
            {job_title: 'HR Manager', dept: 'HR', target: ''},
            {job_title: 'Sales Manager', dept: 'Sales', target: ''},
            {job_title: 'Marketing Manager', dept: 'Marketing', target: ''}
        ];

        rows.forEach(row => {
            const child_row = frappe.model.add_child(frm.doc, 'Child Table DocType', 'child_table_fieldname');
            child_row.job_title = row.job_title;
            child_row.dept = row.dept;
            frm.refresh_field('child_table_fieldname');
        });
    }
});

thank you very mach

i need your help … how can i make dept. field link with department doctype that mean i want to select dept… from the list.

Please set your field name in the script, dept is the department then check the field name and set it.

how can i get child_table_fieldname ?

Please go to the customize form and check the table fieldname.

how can i give permission on the one row only front his job title (Approver) in the table for example direct manager only can write in his row only , HR Dept. only can write on his row only …etc

frappe.ui.form.on('Clearance Letter', {
    onload: function(frm) {
        const rows = [
            {approver: 'Direct Manager', manager_name: '', date: '', note: ''},
            {approver: 'Head Of Dept.', manager_name: '', date: '', note: ''},
            {approver: 'HR Dept.', manager_name: '', date: ''},
            {approver: 'Financial Dept.', manager_name: '', date: '', note: ''},
            {approver: 'DMS Dept.', manager_name: '', date: '', note: ''},
            {approver: 'Legal Dept.', manager_name: '', date: '', note: ''},
            {approver: 'Accountant Assests.', manager_name: '', date: '', note: ''}
        ];

        rows.forEach(row => {
            const child_row = frappe.model.add_child(frm.doc, 'Clearance Letter tab', 'approvers');
            child_row.approver = row.approver;
            child_row.manager_name = row.manager_name;
            frm.refresh_field('approvers');
        });
    }
});

you can see the table below

not possible, you can’t set the role for a particular row.

is there any idea to do like this