I have setup the notification, as below, which is used to send an email when i save this “Attendance request” Doctype
below is the email which is send
Now, i want to add a button (name : Approve), to approve the attendance request, and submit this Attendance request.
Need help how can i do this, any suggestion is appreciated
I had made the notification standard, so that a .md, .json, .py file is made in backend
I think i need to make an API + .md file to make proper flow, anyone know how to do exactly…
1 Like
Hey mate, you might want to consider workflows.
Workflow Actions
1 Like
Yes, you are right, now i am trying to setup the workflow
getting some issue
below is the States in workflow
below is the transition state
when i submit this workflow, it shows below error, which is perfect i know, but i want to add a Reject status, which will be meaningfull.
the problem is, in “Attendance Request” their is no Cancelled status, you can cancel only when the document is submitted, but i want to integrate a “Rejected” status also like it is in “Leave Application”
Anyone, who know how to do this
You can just change the Doc Status for Rejected from 2 to 0,
Because the document is still Draft and can’t cancel draft
I found the solution, we can follow the below steps
- add a file attendance_request_list.js with below code, so that you have a status for "Rejected"in Attendance Request, and “Approved” also
frappe.listview_settings["Attendance Request"] = {
add_fields: ["employee", "employee_name"],
has_indicator_for_draft: 1,
get_indicator: function (doc) {
let status_color = {
"Approved": "green",
"Rejected": "red",
"Draft": "orange"
// "Submitted": "blue"
};
return [__(doc.status), status_color[doc.status], "status,=," + doc.status];
}
};
- now below is the updated workflow setup
- also change small code in attendance_request.py file
def on_submit(self):
if self.status == “Approved”:
self.create_attendance()
so that Attendance document is made only when the Attendance Request is approved
- this is how it will look finally
1 Like