I created new custom fields in the Attendance Doctype to do some calculations for minutes and lates
But when i press Mark Attendance Button from Shift Type DocType, it creates and submit all the records
and my script is not executed
But when entering each record , it is executed
Is there a way to automatically commit changes to all records?
As per my knowledge, setup event is triggered only when the form is initially loaded, while the onload event is triggered both when the form is initially loaded and when itās reloaded or changes are made.
So, if you want your custom script to execute only when the form is first loaded, use setup. If you want it to execute when the form is initially loaded and whenever changes are made to the form, use onload.
i have tried all events ( before_insert, after_insert, on_submit, onload, ā¦ etc )
and nothing happens, and onload works only when i open any attendance record
I want to calculate time between (In Time) and (Start Time) In time is a native field in attendance Start time is a custom field to fetch value from Shift Type Doctype
thanks for the reply
i used custom client script to do the calculation
but it didnāt work when attendance is created.
I want to calculate time between (In Time) and (Start Time) In time is a native field in attendance (datetime) Start time is a custom field to fetch value from Shift Type Doctype (time)
i tried with server script and it is execited with mark attendance button
and i get time defferent between (in_time, out time) or ( start_time, end_time) when i try it
but donāt work with (start_time, custom_in_time_wd) and get error
#this code to delete Date from (in_time, out_time) to only time fields (in_time_wd, out_time_wd)
in_t = frappe.utils.get_datetime(doc.in_time)
doc.custom_in_time_wd = frappe.utils.get_time(in_t)
out_t = frappe.utils.get_datetime(doc.out_time)
doc.custom_out_time_wd = frappe.utils.get_time(out_t)
#this code to calculate the difference between custom_in_time_wd and start time
strt_time=frappe.utils.get_datetime(doc.start_time)
in_time_wd=frappe.utils.get_datetime(doc.custom_in_time_wd)
diff=frappe.utils.time_diff_in_seconds(in_time_wd,strt_time)
doc.custom_test_late_int=diff
but when i press mark attendance i get this error
" AttributeError: ādatetime.datetimeā object has no attribute ātotal_secondsā "