def METHOD_NAME(doc):
	user_permissions = get_user_permissions()
	defaults = frappe.defaults.get_defaults()
	for df in doc.meta.get("fields"):
		if df.fieldtype in data_fieldtypes:
			# user permissions for link options
			doctype_user_permissions = user_permissions.get(df.options, [])
			# Allowed records for the reference doctype (link field) along with default doc
			allowed_records, default_doc = filter_allowed_docs_for_doctype(
				doctype_user_permissions, df.parent, with_default_doc=True
			)
			user_default_value = get_user_default_value(
				df, defaults, doctype_user_permissions, allowed_records, default_doc
			)
			if user_default_value is not None:
				# if fieldtype is link check if doc exists
				if not df.fieldtype == "Link" or frappe.db.exists(df.options, user_default_value):
					doc.set(df.fieldname, user_default_value)
			else:
				if df.fieldname != doc.meta.title_field:
					static_default_value = get_static_default_value(df, doctype_user_permissions, allowed_records)
					if static_default_value is not None:
						doc.set(df.fieldname, static_default_value)