Address_line1 length limit issue

I wanted to limit address line 1 to 30, but If i do so I will give me this warning.

“Reverting length to 140 for ‘address_line1’ in ‘Address’. Setting the length as 30 will cause truncation of data.”

Also, This has affect the custom Address naming series now.

Could you please help me for this?

Thank you.

This is happening because you already have data that is more than 30 characters so DB schema can not be altered to reduce the length. You can truncate those values first before reducing the length.

Alternatively, leave current data untouched and add validation using server script for this instead of changing length at DB level.

if not 0 < len(doc.address_line_1) <= 30:
    frappe.throw("Address line 1 should be between 1 and 30 characters")
1 Like