Is there anyone here, who can help me?
employee_names = frappe.get_all(“Employee”, distinct=True, pluck=“employee_name”)
status_options = frappe.get_meta(“Asset Request”).get_field(“status”).options.split(“\n”)
workflow_states = frappe.get_all(“Asset Request”, distinct=True, pluck=“workflow_state”)
logged_in_user_id = frappe.session.user
employee = frappe.get_all(“Employee”, filters={“user_id”: logged_in_user_id}, fields=[“name”])
if employee:
employee_name = employee[0].name # Get the name of the employee
asset_requests = frappe.db.sql(“”"
SELECT name, employee, employee_name, status, request_type, transaction_date, workflow_state, reports_to
FROM tabAsset Request
WHERE employee = %s
ORDER BY STR_TO_DATE(transaction_date, ‘%%d-%%m-%%Y %%H:%%i:%%s’) DESC;“”",
(employee_name,),
as_dict=True)
else:
asset_requests = [] # Empty list if the user’s user_id doesn’t match an employee’s user_id
context = {
“employee_names”: employee_names,
“status_options”: status_options,
“workflow_states”: workflow_states,
“asset_requests”: asset_requests
}
employee_names = frappe.get_all(“Employee”, distinct=True, pluck=“employee_name”)
status_options = frappe.get_meta(“Asset Request”).get_field(“status”).options.split(“\n”)
workflow_states = frappe.get_all(“Asset Request”, distinct=True, pluck=“workflow_state”)
logged_in_user_id = frappe.session.user
employee = frappe.get_all(“Employee”, filters={“user_id”: logged_in_user_id}, fields=[“name”])
if employee:
employee_name = employee[0].name # Get the name of the employee
asset_requests = frappe.db.sql(“”"
SELECT name, employee, employee_name, status, request_type, transaction_date, workflow_state, reports_to
FROM tabAsset Request
WHERE employee = %s
ORDER BY STR_TO_DATE(transaction_date, ‘%%d-%%m-%%Y %%H:%%i:%%s’) DESC;“”",
(employee_name,),
as_dict=True)
else:
asset_requests = [] # Empty list if the user’s user_id doesn’t match an employee’s user_id
context = {
“employee_names”: employee_names,
“status_options”: status_options,
“workflow_states”: workflow_states,
“asset_requests”: asset_requests
}
#Using this code, I am able to fetch the field data, but I want to fetch child table also from doctype, how to do it?
Thanks and Regards
Shubham