Suppose I have a doctype name workflow Test. It has a workflow approvals system. I want to add every approvals user name on the docs report view.
When user A approves first step then his/her name will be added on that doc
then user B approves 2nd step then his/her name will be added on that doc also dynamically.
Not sure what specially your client is asking for but my proposed solution is to create 2 custom fields in your doc let’s call them “first_approver” & “second_approver” which will hold the user who did the workflow action.
Then map them based on your workflow states (let’s say “Primary Approval”, “Approved”);
# Get the first comment that matches the specified filters
comment = frappe.db.get_all("Comment", filters={
"comment_type": "Workflow",
"reference_doctype": reference_doctype,
"reference_name": reference_name,
"content": comment_content
}, fields=["comment_email"], limit=1) # Limit to 1 to get only the first entry
# Initialize a variable for the email
email = None
if comment:
email = comment[0].get("comment_email") # Get the first email if available
# Initialize a variable for the full name
full_name = None
if email:
# Fetch the user's full name using the email
full_name = frappe.db.get_value("User", {"email": email}, "full_name")
# Log the email and full name
log(f"Email: {email}, Full Name: {full_name}")
i understand but this script is for the print,i dont want that,ijust want to display the names in some fields of the purchase invoice, i can view that via activity tab but still i dont want to scrolldown and add a field in whcih the names of the approvers should be there.