Custom Function for Capitalise(UPPER CASE) the Data while saving

While saving, the input data of all data field must be saved as Capital Letters (Upper Case)

1 Like

The custom python function for Capitalise/making UPPER CASE while saving a document is adding below : :relieved:


def validate(self) : 
     	zbn = frappe.get_meta(self.doctype)
		fieldnames =[x.fieldname for x in zbn.get("fields") if x.fieldtype in ["Data"]]
		if fieldnames:
			for fields in fieldnames:
				if self.get(fields):
					self.set(fields, str(self.get(fields)).upper())

Just Copy-Paste the same in your code. If the py file is in hooks, change “self” to “doc”.
Thank Me Later… :wink:

4 Likes

Hey, Just copy - paste the below code as this will make the name of the document to Upper case too… :wink:

def validate(self) : 
		zbn = frappe.get_meta(self.doctype)
		fieldnames =[x.fieldname for x in zbn.get("fields") if x.fieldtype in ["Data"]]
		if fieldnames:
			for fields in fieldnames:
				if self.get(fields):
					self.set(fields, str(self.get(fields)).upper())
		self.name = self.name.upper()

REMEMBER : If the py file is in hooks, change “self” to “doc”.

2 Likes