How can I find out owner of a document

How can I find out which document DocType belongs to?
For example:
{% set u = frappe.get_doc(“User”, doc.owner) %} {{u.first_name}} {{ u.last_name }}
(this doc belongs to doc.“owner”), how can i see that?

@Leonardo_Augusto

{{ doc.owner }} gives you the owner of the document.

if you want first_name and last_name of user. Then try this,

first_name : frappe.db.get_value("User", doc.owner, "first_name")
last_name: frappe.db.get_value("User", doc.owner, "last_name")

2 Likes

Yes this worked for me. What I want to know is HOW I can do to find out what the document name the variable is. For example, i have to get an variable on quotation list. If is quotation list, the name of the document will be quotation too? Will it always be like this? So the doc.(name_of_document = name of title list)?

Hi @Leonardo_Augusto,
Please check in the Doctype List.

Thanks

Just let do an axemple… I need get the e-mail of my customer, and i find it data on link: /desk#Form/DocType/Quotation and the variable is “email”. So will be like this:
{% set u = frappe.get_doc(“Quotation”, doc.quotation)%}
{{ u.email}}

Its correct?

Hi @Leonardo_Augusto,
Check this
https://frappe.github.io/erpnext/user/manual/en/setting-up/email/email-alerts

Thanks

My doubt is not the email alert, it’s simpler than that…
I just want to know when to call a variable, how can I know which parameter I’m going to put in doc.“here”.
Just it

Thanks Sangram, it helps me.
How can I print the name of user who has edited the specific field in document?
Ex: there are two users: Aruvi (Stock User) and Manjunath (Stock Manager).
Aruvi created the Purchase Receipt, then manjunath edited the supplier name and submitted. I want to print both user details as shown in picture:

image image

““Draft””
{% if doc.workflow_state==“QM Approved” %}
{{frappe.db.get_value(“User”, doc.owner, “first_name”)}}

How should i insert the name of approved user?

if you apply workflow on any document. the related information is going into Communication table.

you have to fetch info from there and have to handle it in Print Format.

{% set test = frappe.get_list(“Communication”, filters={“reference_name”: doc.name}, fields = [“user”,“subject”]) %}

and then iterate through test and print according to user. subject contains the workflow state info

Thank you adnan,
Since I am not in software field I am learning the things.
could u please tell me how to iterate the test, please tell me how to achieve the task with reference to below communication details:

I have to print the field Manjunath

{% set test = frappe.get_list(“Communication”, filters={“reference_name”: doc.name}, fields = [“user”,“subject”]) %}
{%- for row in test -%}
{% if row.subject == “SM Approved” %}
{{ row.user}}
{% endif %}
{% endfor %}

use the above code.
and in if conditions, you can apply all workflow states to print it’s approved user

it gives error:
should I mention fieldname somewhere (workstate_flow)?

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/app.py”, line 62, in application
response = frappe.handler.handle()
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 22, in handle
data = execute_cmd(cmd)
File “/home/frappe/frappe-bench/apps/frappe/frappe/handler.py”, line 53, in execute_cmd
return frappe.call(method, **frappe.form_dict)
File “/home/frappe/frappe-bench/apps/frappe/frappe/init.py”, line 939, in call
return fn(*args, **newargs)
File “/home/frappe/frappe-bench/apps/frappe/frappe/www/printview.py”, line 188, in get_html_and_style
no_letterhead=no_letterhead, trigger_print=trigger_print),
File “/home/frappe/frappe-bench/apps/frappe/frappe/www/printview.py”, line 159, in get_html
html = template.render(args, filters={“len”: len})
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/jinja2/environment.py”, line 1008, in render
return self.environment.handle_exception(exc_info, True)
File “/home/frappe/frappe-bench/env/local/lib/python2.7/site-packages/jinja2/environment.py”, line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File “”, line 1, in template
TemplateSyntaxError: unexpected char u’\u201c’ at 30

post your code here. no one can help without the code you are working on.

I have just copied the code u have mentioned above

{% set test = frappe.get_list(“Communication”, filters={“reference_name”: doc.name}, fields = [“user”,“subject”]) %}
{%- for row in test -%}
{% if row.subject == “SM Approved” %}
{{ row.user}}
{% endif %}
{% endfor %}

{{ frappe.get_fullname(doc.owner) }}