Custom field in Core Doctype

Can we add custom field in core doctypes like Users using customize form?

AFAIK, we couldn’t add more fields, even directly thourgh Custom Field doctype. The most we can do is to set some property using Property Setter doctype.

Hi @Rehan_Ansari:

Is not allowed with form customization. You can achieve this creating a custom field via fixtures, or with some “witchery” (changing on your develop system wich doctypes allows custom fields)

Check this.

Hope this helps.

1 Like

@avc

Hey @Rehan_Ansari
Try @avc approach
Comment out User doctype from the core_doctypes_list, add the field in User doctype, and export it via fixtures or a customized form. Then, uncomment the User doctype from the core_doctypes_list. Hope this helps!

@ejaaz So by doing this on the development setup it will not affect the production site after deploying this custom code via custom app?

I have done this in my local setup, exported the custom field in my custom app, and deployed it to the server; it worked properly in my case. You can verify by testing on one more local site.

1 Like

@Rehan_Ansari
There is one more approach: if you want, you can use it to add fields in the after_install hook.

Reference

Simply run this code in System Console, after changing the label and fieldname and other properties as you want.

custom_field = frappe.new_doc(“Custom Field”)
custom_field.dt = “User”
custom_field.label = your_field_lable
custom_field.fieldname = fieldname
custom_field.fieldtype = fieldtype
custom_field.read_only = 1
custom_field.insert_after = “”
custom_field.save(ignore_permission=1)

1 Like