I found there are two ways to add fields to Doctype. One is using Custom Field, One is opening the DocType and adding new rows. For the first way will adding records to tabCustom Field table and not change json file, for the second way will change json file and not adding records to tabCustom Field table.
I’d like to know what else difference between these two ways, and which way is better?
You can use the First way as you say otherwise you can use this way
1.go to the Doctypes List
2. Select Doctype for adding the field.
3.Select on that Doctype and add the field where you want to add.
New Indictrans Technologies Pvt. Ltd
@Jasmine To answer you query please note that there can be 2 types of doctypes:
Doctypes which are part of standard product (like Sales Orders, Item, Customer etc etc)
Doctypes which are made by users as a customization to the erpnext product.
Now if you are wanting to add fields to standard doctypes then you should follow what @System19 said and should not try and mess with standard product since messing would be problematic in case the team makes some changes to that doctype at their end and you would end up with a broken update.
Also you can now add custom fields directly from customize form view and there is no need to go to custom fields page separately.
Now if you have created your own doctype then using custom fields is not going to be the ideal way, in this case you should add the fields directly to the doctype so that the changes are part of the customization.
Please note that when I say “on you own doctype” I have already assumed that you have an app on github to manage your customizations.
I tried what you said. It works, but the output under /erpnext/erpnext/fixtures are json files, not the cvs as you said. However this json file include the data in Custom Field. Just wondering if it can create a csv file.
Thats odd. In Ver 6.4
I get a fixtures folder created with a file inside it called custom_field.csv .
It is located at: ~/erpnext/frappe-bench/apps/erpnext/erpnext/fixtures/custom_field.csv
If you were to export another doctype with data in it, Say for example the Customer Doctype (via the import option in the Customer Doctype dropdown menu).
Then open that file from your downloads folder in your text editor and you should see a very similar comma separated format.