You can check what fields were changed or new values were added via Version
There is a hidden field called data in that latest Version instance of your Payment Entry which contains a string which is a dictionary which records fields were newly added and which ones were updated. Here’s an example of an update:
The error is saying that your Payment Entry object has no such attribute called data.
This field data is not a field in the Payment Entry but the Version instance of this Payment Entry. You need to fetch the latest version document of your current Payment Entry. Try something like this:
This method will get you the Version object which contains the changes done to this payment entry. Then you can use pe_last_change.data You can ofcourse use object names as per your requirement and the context to make your code more readable.
Clarification for usage of self in the above method
If you already are well verse with Python then you can skip this one. If not please read.
Just to clarify, that you can use self.doctype only if this is a function defined in the Class itself. BUT this function is called from JS or any function out of the scope of class, then make sure that you pass the Payment Entry name field which makes the usage of get_doc or other Frappe methods to get values easier. If it is the latter case, then use the appropriate object name you defined.
retuns now Version {'docname': u'PE-00020', 'ref_doctype': u'Payment Entry'} not found
I checked doctype Payment Entry for track changes option - it’s enabled.
I’m replaced self.doctype and self.name in your code with the same values passed to the method with doc object. Maybe it’s my mistake and values in your code string means somthing different?
def transfer_confirmation_check(doc,event):
if not doc.get('__unsaved'):
saved_doc = frappe.get_doc('Payment Entry', doc.name)
if saved_doc.creditdecision != doc.creditdecision:
# do something if creditdecision field is changed by user
else:
# Some validation if doc item is new here