I am using client script to the User doctype. Here, I want to access the data of child table Doctype Email And Site which has parent Doctype Support User Branch Setting. I want to delete the row in the child table if the email from User’s email matches the user_email (field_name of child table) and has no role for Support Team from that row after saving the doc.
Please see the code below.
frappe.ui.form.on('User', {
after_save: function (frm) {
if (frm.doc.name && frm.doc.roles) {
var isSupportTeam = false;
for (var i = 0; i < frm.doc.roles.length; i++) {
if (frm.doc.roles[i].role === 'Support Team') {
isSupportTeam = true;
break;
}
}
if (isSupportTeam) {
console.log("hello");
frappe.call({
method: 'frappe.client.get_list',
args: {
doctype: 'Email And Site', //child Table of Support User Branch Setting
filters: {
parent: 'Support User Branch Setting'//
},
fieldname: ['user_email']
},
callback: function(response) {
if (response.message) {
// Process the retrieved data
var childTableData = response.message;
for (var i = 0; i < childTableData.length; i++) {
var childRow = childTableData[i];
var field1Value = childRow.user_email;
// Do something with field1Value and field2Value
console.log("Field 1 Value: " + field1Value);
console.log("Field 2 Value: " + field2Value);
}
}
}
});
}
}
}
});
I got an error after saving the doc