Updating field value based on another doctype field value,

Hi @ibalajib,

Automatically update for use server script like this:
Document Type: Holiday List
DocType Event: After Save Or Before Save (Set and check your according.)

# EDIT Code
test_name = frappe.db.get_value("Custom DocType",{'working_id':doc.name},'name')
if test_name:
    test_doc = frappe.get_doc("Custom DocType",test_name)
    from_date = doc.from_date;
    to_date = doc.to_date;
    holidays = frappe.datetime.get_day_diff(to_date, from_date);
    final_holidays = holidays - doc.total_holidays + 1;
    test_doc.duration = final_holidays;
    test_doc.number_of_leaves = doc.total_holidays;

Do not remove the custom/client script.

Please apply and check it.

Thank You!

1 Like