Make custom script sample as template for easy custom script creation

Normally end user / customer create their own custom script by copying from referenced sample script and adapt it to the relevant doctype and field, currently the sample custom script in the user manual and other useful script scattered in the forum and wiki page are the most important source for reference/copy.

I am thinking whether it is feasible or possible to further integrate those sample custom script into ERPNext itself, and make it readily for search and copy in the custom script screen ? to be more specific, we need to do the following

  1. add one doc type: sample custom script (or call it custom script template) with the following fields

    name, define it searchable
    description, define it searchable
    script code, have special formatted placeholder fieldds in it, define it searchable

  2. enhance the custom script form to allow searching the sample custom script, showing a popup window if there is placeholder fields in the sample script, in the popup window set the extracted placeholder fields as input field, under most of the cases the doctype and/or docfield will be the input .
  3. after the sample script copied , user is free to edit manually.
1 Like

I really like this idea as it moves ERPNext towards FileMaker Pro in user friendly functionality. As you mentioned:
Before starting this we need to centralise all Installation, Custom Script and Server Side tutorials/examples.
Each frappe field type should have examples of increasing complexity. So for the Button field, Button that goes back or forward a page, Button that links to an internal/external url, Button that pulls info, Button that does something else fancy, etc etc.

I am now also thinking another option to implement the same

  1. Define a dummy doctype,
    2.Maintain the sample custom script by referring to the dummy doctype in the current custom script doctype, in the script use special placeholder syntax e.g {{doctype}} , also add one more field to store some usage guidance info for easy search / filter
  2. user located to the corresponding sample script via search or filtering, click duplicate, then choose the doctype to be applied, also add the helper field link to docfield(this is the idea from Odoo, in its email template and server action screen, user can choose model and field, then system auto generate the technical field name ready for copy and use in email content or code), by choosing the target field to be manipulated in the script, system will auto replace the placeholder variable by the selected doctype and docfield accordingly.