rappe.listview_settings["Employee Checkin"] = {
refresh: function(listview) {
for (var i = 0; i < listview.data.length; i++) {
var row = listview.data[i];
let collection = document.getElementsByClassName("list-row-container");
var shift = row.shift;
var emp = row.employee;
var t = row.time;
if (emp == 6 && shift == "shift2"){
console.log("i am here");
frappe.call({
method: "erpnext.hr.doctype.employee_checkin.employee_checkin.add_log_based_on_employee_field",
args: {
employee_field_value: emp,
timestamp: '06-09-2023 16:00:00',
device_id: 'test3',
log_type: '',
skip_auto_attendance: 0,
employee_field_name: emp
},
callback: function (r) {
console.log(r.message);
}
})
}
}
}
}
any help please ??
i am trying to add employee checkin record automatically based on certain shift .
i tried to call the method add_log_based_on_employee_field but it did not work , this error comes >>
It looks like you’re encountering a couple of issues with your code.
The 500 (INTERNAL SERVER ERROR) typically indicates a problem on the server side, and
the DOMException is related to Chrome’s autoplay policy.
Let’s address these one by one.
500 Internal Server Error
This error message suggests that there might be an issue with the add_log_based_on_employee_field method call. Here are a few things to check -
My guess is - Method Path - Ensure that the method path is correct. The correct path should be erpnext.hr.doctype.employee_checkin.employee_checkin.add_log_based_on_employee_field.
My doubts on Arguments too - Verify that all required arguments are being passed correctly. The method might be expecting specific arguments that are not being provided correctly. Not sure what exactly - you may have to value add here please.
The “DOMException” related to Chrome’s autoplay policy is likely due to an attempt to play media (like audio or video) without user interaction. This can be ignored if it’s not affecting your main functionality.
I have revised the code - please check.
frappe.listview_settings["Employee Checkin"] = {
refresh: function(listview) {
for (var i = 0; i < listview.data.length; i++) {
var row = listview.data[i];
var shift = row.shift;
var emp = row.employee;
var t = row.time;
if (emp == 6 && shift == "shift2") {
console.log("i am here");
frappe.call({
method: "erpnext.hr.doctype.employee_checkin.employee_checkin.add_log_based_on_employee_field",
args: {
employee_field_value: emp,
timestamp: '2023-09-06 16:00:00', // Ensure the timestamp format is correct
device_id: 'test3',
log_type: '',
skip_auto_attendance: 0,
employee_field_name: 'employee' // Ensure this is the correct field name
},
callback: function (r) {
if (r.message) {
console.log(r.message);
} else {
console.error("Error: No message returned");
}
},
error: function (r) {
console.error("Error: ", r);
}
});
}
}
}
};