Custom Scripts

If you wish to change any ERPNext form formats, you can do so by using Custom Scripts. For example, if you wish to add a submit button after saving, to a Lead form, you can do so by creating your own script.

Home > Customization > Form Customization > Custom Script

Custom Script

1. How to Create a Custom Script

Create a Custom Script (you must have System Manager role for this):

  1. Go to Custom Script List and click on New.
  2. You will be redirected to a page wherein you will be asked to enter the DocType for which you wish to create a Custom Script.
  3. Type your Custom Script and make sure it is enabled.
  4. Save.

2. Notes

  • Server Custom Scripts are only available for the Administrator.
  • Client Custom Scripts are in JavaScript and Server Custom Scripts are in Python.
  • For testing, make sure to go to Tools > Clear Cache and refresh after updating a Custom Script.

2. Custom Script Examples

Here are some custom script examples:

  • fetch-values-from-master
  • date-validation
  • generate-item-code-based-on-custom-logic
  • make-read-only-after-saving
  • restrict-cancel-rights
  • restrict-purpose-of-stock-entry
  • restrict-user-based-on-child-record
  • sales-invoice-id-based-on-sales-order-id
  • update-date-field-based-on-value-in-other-date-field
  • custom-button
  • filter-options-in-select-field
  • fetch value in child table field
  • hide-buttons-in-form-view
  • rename-buttons-in-form-view
  • lock_timesheets_based_on_date

3. Videos