Adding new Fields to ERPNext CRM Lead DocType from Custom App

I’m writing a custom app to add my CRM bussiness logic into ERPNext CRM, how can i add new fields to DocTypes from my custom app, I’ve read about custom fields and hooks.py fixture but i can’t understand how to that could do what i need

Fixtures are just doctype records that are stored permanently on the file system (rather than in the database). They get imported on each bench migrate. Since custom fields are just records of the doctype Custom Field, you can create a fixture for them just like you would anything else.

Usually you export fixtures from the command-line, but there’s a more convenient way for forms. Use the Customize Form tool to make whatever changes you want, then hit the Actions button and select Export Customizations.

3 Likes
  1. Add patches folder if not there in your custom app
  2. Create and place your patch to add custom field. (you can create version wise folder as well)
  3. Add patches.txt file (if not there in your custom app)
  4. Add patch entry to patches.txt
  5. Run bench migrate

See below for reference

1 Like

Thanks alot for your explanation, i have a site which has the apps frappe, erpnext, and my_custom_app when i add custom field on that site where should i create my custom field. I think when i add custom field to lead doctype for example and exporting fixtures

  1. How should the app knows that this custom field is a fixture and it should be exported
  2. The exporting result or files where be in the erpnext app not in my custom app how can i specify that i want this field to be exported to my app not to erpnext app

All custom fields get exported. If you want to export only some custom fields, you’ll have to edit the fixtures file manually.

When you submit the export, you’ll be asked which module you want to export to. If you pick a module from your custom app, the customizations will be saved there.

2 Likes

Thanks alot. it has worked perfectly thanks alot. For two weeks i’ve been searching for how can i achieve this.

Thanks again for you support. :heart:

1 Like