Writting Doctype Script

Hello guys. I’m a beginer in erpnext. I created a custom Doctype. Now I want to add service side script and client side script but I don’t know where to start. I pulled erpnext repo and read some but i can’t understand all ideas of scripts. So, please let me know how to write scripts and explain ideas for writting scripts for me. Thanks all.

First you need to allow developer mode in your site then start writing the script. For that go to your setup folder in that frappe-bench>sites>your site name>site_config.json, open this file site_config.json and add
“developer_mode”: 1 below your db_password like this:
“db_name”: “xxxxxxxxxxxx”,
“db_password”: “xxxxxxxxxxxx”,
“developer_mode”: 1

yes. I did it. and i created custom doctype. Now, I need add client side script (javascripts file) and server side script (python file). But i don’t know how to write it. Can you describle what i should write ? thank you.

For client side you need to write code in custom script and for server side you need to make script report and in back-end you will get .js file and .py file for writing code

Yes. Thank you. But i don’t know how to write it. what i mean that i don’t know the content of scripts file. what idea should i write. i read some erpnext module but i don’t understand what they wrote.

Try with something simple:
validate event will trigger automatically when you save the document. It is the default event of frappe just like ‘onclick’ in html
-------on .js file----------------------
validate: function(frm)


here you can find more about client side triggers:

These links will help
Client Side-

Server Side-

Yep. I read all documents above. But, i actually want to ask that the content of script files. what standard should i follow to wirte? Because I don’t know what things i should write from begin to end.

You can follow the standard of ERPNext files itself. Once you read a few Python/JS files you will get the hang of it.

Here is something important to know : Frappe Hooks

I would recommend to try following these basic tutorials before you build a project by yourself , scripting becomes a lot more easier follow these steps and once you get the functionality you can understand and write the scripts fluently , thanks .

1 Like