How can you fetch the one who approved/submits?

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?

Thank you hope you get my case.

you can enable track changes fields from DocType to track the document.

if you want submitted_by then you have to customize that particular DocType.

Thank you for helping me again however, my problem is like this

I have this 3 field where in 1 would only appear every time someone submits the file.

Workflow:

Draft → Pending Request → Pending Approval → Approved

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?

Hope you get our case. Again thank you so much.

To search the code try something like this
frappe@ubuntu:~/frappe-bench$ find . -name ‘*.js’ | xargs grep ‘changed value of’

That leads to this code here
https://github.com/frappe/frappe/blob/develop/frappe/public/js/frappe/form/footer/timeline.js#L560

https://github.com/frappe/frappe/blob/develop/frappe/public/js/frappe/form/footer/timeline.js#L663

To help with your learning best to check out the Version doctype.

3 Likes

You mean you want to set these fields’ values with the users who carried out those operations ?

Would gladly check this. Thank you!

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.

1 Like

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 am stumbling into a similar use case.

I will try using a specific hook for the Submit button and a custom field. (Link: User)
Another Custom field: Datetime of Submittal.

When user submits, fields must be populated by username and datetime. This will allow to fetch that specific value.

Will confirm if it works.

Hi @Tropicalrambler
Did you make it work?

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.

So a submitted_by field would be so helpful.

Here is an example I used to get the User who check the Purchase Invoice and also get the User who Approved. Hope that will help you.

Blockquote
{% set check_user, check_date = frappe.db.get_value(“Comment”, {“reference_doctype”: “Purchase Invoice”, “reference_name”: doc.name, “content”: “Check”}, [“owner”, “modified”]) %}
{% set approve_user, approve_date = frappe.db.get_value(“Comment”, {“reference_doctype”: “Purchase Invoice”, “reference_name”: doc.name, “content”: “Approved”}, [“owner”, “modified”]) %}