How to add document link in Email Template

Hello,

Can anyone tell me on how to add a document link in the Email Template?

Scenario: When an Employee applies for a leave application, the follow via email is checked. An Email Template called Leave approval notification will be sent to Leave approver. But there is no link to that particular document in the notification mail.

So, is it possible to include document link, so that leave approvers can click on that link and get to that document? Same thing should be applicable for Leave status notification template.

Please help.

Thanks & Regards,
Sujay

1 Like

I think this can help in your email template (any email template or doctype);

<a href="{{ frappe.utils.get_url_to_form(doc.doctype, doc.name) }}">{{ doc.employee_name}}'s Leave Application </a>

Cheers

3 Likes

Hello,

Can you please tell me where should I include this code?

Should be included in your email alert (notification in v11). Here’s an example of a notification I use

<h3>New Customer Issue</h3>

<p>A new customer issue has been recorded for {{ doc.customer }} by {{ doc.owner }}. Kindly view details below and take necessary action.</p>

<p> Link: <a href="{{ frappe.utils.get_url_to_form(doc.doctype, doc.name) }}">{{ doc.customer }} Customer Issue </a> </p>

<!-- show last comment -->
{% if comments %}
Last comment: {{ comments[-1].comment }} by {{ comments[-1].by }}
{% endif %}

<h4>Details</h4>

<ul>
<li>Customer: {{ doc.customer }}
<li>Priority: {{ doc.priority }}
</ul>

4 years later I want to achieve something like this, but: It seems that in newer versions (I’m using v14) {{frappe.utils.get_url_to_form(doc.doctype, doc.name)}}“>{{doc.name}}” returns a private url that can only be accessed by people who are logged in. But I want to achieve something like “View this in your browser” when “Send document web view link in email” is enabled. Where the link contains some kind of key that makes the file accessible without being logged in. Any idea how i could achieve this? Thanks :slight_smile:

Here it is : {{frappe.utils.get_url_to_form(doc.doctype, doc.name)}

Sadly with this code it only works when you are logged in, i need something where you can access the invoice pdf online over a link (without being logged in in erpnext)

This is an exemple for Delivery Note :

{{frappe.get_url()}}/delivery_note/{{doc.name}}?key={{frappe.get_doc(doc.doctype, doc.name).get_signature()}}

1 Like