Capturing Name of Approver of Workflow Action that Submits a Document

Hi,

We seem to struggling more than we should about this:

Let’s say there is a Workflow action that submits a document (say a Purchase Order). All we want is for the name of the person (carrying out the workflow action that submitted the document) to be captured in a custom field of the document.

Is is possible to do this? If yes, how.

We tried to replicate the suggestions in this link: After workflow action, but without too much success.

Thanks

Jay

2 Likes

if you only need to make the submit user name available on print format, maybe you can refer to the below monkey patch

in print format you can use {{doc.get_submit_username()}}

you can access the source erpnext_oob/monkey_patches/base_document.py · 余则霖/ERPNext开箱即用 - Gitee.com

I’m using this to get the Approve User and Date

{% set approve_user, approve_date = frappe.db.get_value(“Comment”, {“reference_name”: doc.name, “content”: “Approved”}, [“owner”, “modified”]) %}

Hope that help

1 Like

This is possible. I created three fields: a check field, a data field for storing the person’s name, and a date field to hold the date. All three fields are filled and saved BEFORE the workflow action is triggered. See the image below:

See the JS code below:

frappe.ui.form.on(‘Leave Application’, {
 sick_leave_approval_check:function (frm) {
       if (frm.doc.sick_leave_approval_check == 1){
           frm.set_value({
        sick_leave_approved_by: frappe.session.user_fullname,
        sick_leave_approval_date: frappe.datetime.nowdate()
 });
       }
       
if (frm.doc.sick_leave_approval_check !== 1){
           frm.set_value({
        sick_leave_approved_by: null,
        sick_leave_approval_date: null
           });
       }        
}
});
1 Like