i have parent doctype which name ‘issue’ on that there is on workflow
when workflow status equal to ‘Completed’ then all this employee in this child doctype table ‘status’ change to ‘Completed’
how to achieve this
i have parent doctype which name ‘issue’ on that there is on workflow
when workflow status equal to ‘Completed’ then all this employee in this child doctype table ‘status’ change to ‘Completed’
import frappe
def on_update(doc, method):
if doc.workflow_state == "Completed":
for child in doc.technician:
child.status = "Completed"
doc.save()
you can write a script like this.
Also, you can directly set the script on server script doctype.
i have use this script that script only change the status but not save it
frappe.ui.form.on(‘Issue’, {
// Trigger when the form is loaded or refreshed
refresh: function(frm) {
update_custom_technician_status(frm);
},
onload: function(frm) {
update_custom_technician_status(frm);
}
});
function update_custom_technician_status(frm) {
// Check if workflow state is ‘Completed’
if (frm.doc.workflow_state == ‘Completed’) {
// Loop through the ‘custom_technician’ table and update ‘status’ field
$.each(frm.doc.custom_technician || , function(index, technician) {
technician.status = ‘Completed’;
});
// Refresh the custom_technician table to reflect the changes
frm.refresh_field('custom_technician');
// Save the custom_technician table and the Issue doctype
frm.save()
.then(() => {
// Reload the document after saving
frappe.msgprint(__('Issue and technician statuses updated.'));
frm.reload_doc();
})
.catch((err) => {
console.log(err);
frappe.msgprint(__('Error updating issue or technician status.'));
});
}
}
my scenario is in this table show those employee only whose status is ‘Completed’
using this script status change to completed but in this table that completed status employee not show