Hi,
I am using the client side frappe.call
with method: frappe.client.get_list to get the employees on specific filters.
Further for each of the employee records, literating through forloop and using
another frappe.call with method
frappe.client.get_value
But here i am unable to get routes to the doctype object.
the logic is as follows
fetch all employees
{
for each employee
{
create table row and then list employee fields as columns
but here I am unable to link to employee a href='#Form/Employee/???
}
}
Any ideas to get the rout to link to each employee doctype object from frappe.client.get_value will help a great help. It is bez get_value only provide doctype fields and not able to get the route to the object.
My code is as follows
var show_visa_expiry_employees = function(me){
frappe.call({
method: ‘frappe.client.get_list’,
args: {
'doctype': 'Employee',
filters:{'visa_exp': ['<', frappe.datetime.add_days(frappe.datetime.nowdate(), 60)],
'status': 'Active'
},
limit_page_length: 20
},
callback: function(r) {
details="";
if (!r) {
// code snippet
details = "<div>" + 'No Employee records found' + "</div>";
me.page.main.find(".visa_expiry").html(details);
}else{
for (i=0; i < r.message.length; i++) {
frappe.call({
method: 'frappe.client.get_value',
args: {
'doctype': 'Employee',
'filters': {'name': r.message[i].name},
'fieldname': [
'first_name',
'last_name',
'department',
'company',
'visa_no',
'visa_exp'
]
},
callback: (rr) => {
listTable="<tr>";
listTable=listTable+"<td>"+ rr.message.first_name +"</td>";
listTable=listTable+"<td>"+ rr.message.last_name +"</td>";
listTable=listTable+"<td>"+ rr.message.department +"</td>";
listTable=listTable+"<td>"+ rr.message.visa_no +"</td>";
listTable=listTable+"<td>"+ rr.message.visa_exp +"</td>";
listTable=listTable+"<td>"+ "<a href='#Form/Employee/'"+rr.message+">"+ "Edit"+"</a>"+"</td>";
listTable=listTable+"</tr>";
me.page.main.find(".tab_visa_expiry").append(listTable);
},
error: (rr) => {
// on error
}
})
}
}
}
});
};