Capitalize all Data fields using

frappe.get_meta() is the best thing that Frappe brought to the world. This code capitalizes all fields of datatype Data using the str.upper() method.

Step 1: Create a python class in which you add the following methods.
def return_fields_to_capitalize(doc):
meta = meta = frappe.get_meta(doc.get(“doctype”))
fieldnames =[x.get(“fieldname”) for x in meta.get(“fields”)
if x.get(“fieldtype”) in [“Data”]]
return fieldnames
def capitalize_essential_fields(doc , state):
fields_to_capitalize = return_fields_to_capitalize(doc)
if fields_to_capitalize:
for d in fields_to_capitalize:
if doc.get(d):
doc.set(d, str(doc.get(d)).upper())

Step 2. Add a before_save hook in your to reference it.
Step 3: bench restart