Doc Type Field creation Through Code Level

I want to create a field in the existing doctype through code level, rather than using UI.
Any suggestions to do the above requirement?

Thanks in Advance

you can change the json file inside the doctype folder and then do bench build and restart . but I don’t recommend it .

@bahaou Thanks for your response.

If that’s not a recommended way, my use case was below scenario

We have two different sites with multitenancy mode. Both sites have the same doctype and fields. Admin adds a new field in the doctype (Site A), we need to do the same changes in Site B doctype through any scripts or something. without doing any manual work.

How do we achieve the use case?

Thanks in Advance

you can refer the guide below

Use create_custom_fields function.

Example: ecommerce_integrations/ at f02cc4e51e83139d00db554c09df5d6668e6efb8 · frappe/ecommerce_integrations · GitHub

1 Like