Hi,
Is there any way that we can send an email alert for the changes made in a document.
Like we get at the bottom of the Doctype:
- Who did changes?
- What changes he did?
- What was the old value and what is the new value of that field etc.?
Regards
Ruchin Sharma
@ruchin78,
You can create the Email Alert on Version doctype
@makarand_b
But what will be the contents of the email?
Edit: And how to restrict the email alert for a particular doctype let say Item, means it should only email if the doctype is Item.
Regards
Ruchin Sharma
@ruchin78,
You can add the condition in email alert and check the doctype.
e.g. doc.ref_doctype == “Item”
Hi @makarand_b
I am not able to show the details in the email alert for the changes done in a particular document.
I was referring this:
{% if data.comment %}
<h4>{{ __("Comment") + " (" + data.comment_type }})</h4>
<p>{{ data.comment }}</p>
{% endif %}
{% if data.changed and data.changed.length %}
<h4>Values Changed</h4>
<table>
<thead>
<tr>
<td style="width: 33%">Property</td>
<td style="width: 33%">Original Value</td>
<td style="width: 33%">New Value</td>
</tr>
</thead>
<tbody>
{% for item in data.changed %}
<tr>
<td>{{ frappe.meta.get_label(doc.ref_doctype, item[0]) }}</td>
<td>{{ item[1] }}</td>
<td>{{ item[2] }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% set _keys = ["added", "removed"] %}
{% for key in _keys %}
{% if data[key] and data[key].length %}
{% if key=="added" %}
<h3>Rows Added</h3>
{% else %}
<h3>Rows Removed </h3>
{% endif %}
<table>
<thead>
<tr>
<td style="width: 33%">{{ __("Property") }}</td>
<td style="width: 67%">{{ title }}</td>
</tr>
</thead>
<tbody>
{% set values = data[key] %}
{% for item in values %}
<tr>
<td>{{ frappe.meta.get_label(doc.ref_doctype, item[0]) }}</td>
{% set item_keys = keys(item[1]).sort() %}
<table>
<tbody>
{% for row_key in item_keys %}
<tr>
<td>{{ row_key }}</td>
<td>{{ item[1][row_key] }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% endfor %}
{% if data.row_changed and data.row_changed.length %}
<h4>{{ __("Row Values Changed") }}</h4>
<table>
<thead>
<tr>
<td style="width: 25%">{{ __("Table Field") }}</td>
<td style="width: 9%">{{ __("Row #") }}</td>
<td style="width: 22%">{{ __("Property") }}</td>
<td style="width: 22%">{{ __("Original Value") }}</td>
<td style="width: 22%">{{ __("New Value") }}</td>
</tr>
</thead>
<tbody>
{% set values = data.row_changed %}
{% for table_info in values %}
{% set _changed = table_info[3] %}
{% for item in _changed %}
<tr>
<td>{{ frappe.meta.get_label(doc.ref_doctype, table_info[0]) }}</td>
<td>{{ table_info[1] }}</td>
<td>{{ item[0] }}</td>
<td>{{ item[1] }}</td>
<td">{{ item[2] }}</td>
</tr>
{% endfor %}
{% endfor %}
</tbody>
{% endif %}
But it always give me template error,
Anyone, any idea about this?
bump
I would need this as well.
At first, I thought the comment template was it but it does not include track changes. ;(