Email Alert of Document Changes

Hi Community,

I would like to receive email alerts for changes.

I understand that changes are created in Version Doctype.

This appear under table_html field, type: html

How do I get this information appear in the email alert?

I have tried all methods but still cannot get it
{% set html_field = doc.html_field %}

{{ html_field | safe }}

Hi:

Changes are stored in JSON format, into a field called data on “Version” doctype.

I don’t know exactly from where are you trying get this … Notification doctype?
Anyway, try this:

{{frappe.db.get_list('Version',
    filters={
        'ref_doctype': 'Customer',
        'docname': 'Customer 01'
    },
    fields=['data'],
    order_by='creation desc',
    limit=1
)}}

This will show the last changes on Customer 01
Hope this helps.

Hi @avc

Many thanks for the direction given.

I am trying to email notification changes made in Lead doctype to users.

Using {{doc.data}} , I managed to get the changes in JSON format.

{“added”:,“changed”:[[“remarks”,“Hi do u have 100sqft -120sqft storage sp=
ace.\nIntend to lease for 6mths - 12mths\nStowing personal household and ev=
ent stuffs.\n\nMove in date: 11 sept 23\n\nMay l know how is the lease proc=
ess n how much?\n\nThanks!!”,“Hi do u have 100sqft -120sqft storage space.=
nIntend to lease for 6mths - 12mths\nStowing personal household and event s=
tuffs.\n\nMove in date: 11 sept 23\n\nMay l know how is the lease process n=
how much?\n\nThanks!!!”]],“data_import”:null,“removed”:,“row_changed”:=
,“updater_reference”:null}

In the Jinja template, I am trying to make a table using the above JSON . However, it is not picking up the items in the array.

		{% for item in doc.data.changed %}
		<tr>
			<td>{{ frappe.meta.get_label(doc.ref_doctype, item[0]) }}</td>
			<td class="diff-remove">{{ frappe.utils.escape_html(item[1]) }}</td>
			<td class="diff-add">{{ frappe.utils.escape_html(item[2]) }}</td>
		</tr>
		{% endfor %}

Ref: frappe/frappe/core/doctype/version/version_view.html at develop · frappe/frappe · GitHub