Good day! How can you fetch the one who approved/submits the file?
I have 3 workflow state which are:
Pending Request
Pending Approval
Approved
I have tried using the following:
Pending Request = doc.owner
Pending Approval = doc.modified_by
Approved = doc.modified_by
However the problem with the approved = doc.modified_by is that you need to save it first before you submit the file for it will not change the modified_by name. Is there a way to fetch the one who submit? like doc.submitted_by?
So what I did was when someone submits the draft to pending request it will fetch the doc.owner and put it on the “prepared by” field then once the manager views the file as pending request he/she will just click a button “submit” then it will fetch the doc.modified_by and put it on the “noted by” field, however the problem with doc.modified_by is that you need to change something/save it first before you submit it, for it will not change the modified_by is there a way to fetch this area?
Sorry for I really don’t get your question however my case is that I would like to automatically fill those fields according to who created the file and who submitted the file.
Like:
Draft
Prepared By = Doc.Owner (Because he’s the one who created the file)
Pending Request
Noted By = Doc.Modified_by (Because he confirmed that the infos inside the file is correct and submitted it for approval)
Pending Approval
Approved By = Doc.Modified_by (He approves if the file is ready to be executed)
We just want it to automatically fill those signatories according to whoever submits the file to reduce errors like having someone use your name in the signatories.
Yes I think so root13F, kelscey90 first you must learn how the current workflow is implemented in the code before you can perhaps customize it to work in your use case
I have the same problem. Using modified_by to retain the approval user is very dangerous, because sometimes the document is updated automatically after approval due to some background processes (e.g. when payment was made for an invoice) and the modified_by user will be overwritten.
# 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}")