Backend Scripting using JavaScript

Hi guys!

I want to start an discussion about the new functionality that I’m building for frappe.

It’s an javascript engine based on duktape
Rightnow, it’s able to do silly things, like get an value from the database, send it to the UI using frappe.msgprint.

That idea is basedly on a pull request from @szufisher, with the difference that I’m not using python as scripting language on the backend, because it’s really hard to sandbox.

I’ll continue working with other features, like function documentation, and a better event subscription.
Also the ability to syncronize one document from the engine with the database.

Any comment, idea will be fully appreciated.

The code is here


I tried it, looks good so far!

1 Like

@snv thanks for the feedback

1 Like

It is creative, very promising.
I would like to propose adding the following typical use case into either the tests or documentation

  • Validation
  • Substitution
  • Create new docs populated with field values from existing docs
  • Sending email
  • Trigger new workflow

Also to make the coding more intuitive and user friendly,

  • Provide a list of available functions for selection,
  • provide doctype and the fields list, support select and drag the field to the code,
  • provide sample code for easy copy
  • Realtime check the syntax, show errors before save accordingly

Here the tableau compute field editor for your kind reference

  1. when input any text(keyword) system will prompt the matched available function in a popup list for easy selection, like dynamic awesome complete, this same feature is implemented for tags
  2. on the right side, the available functions and detailed documentation for selected function is shown, double click the selected function will copy the function name to the current cursor position
  3. Realtime syntax check the code and show the error
  4. the code editor is in a popup window, in the main window, the field of the worksheet(doctype) from the main window can be drag and dropped to the code field.

@szufisher, @snv

I’m here again, but I build one video rightnow to let it speak by my self.

@snv just one answer for your comments.
I really appreaciate your comments and ideas here, but this is something that I have tried in the past some times,

As you can see here


But for many reasons, it’s really hard to be done.
I’ll publish a bunch of updates on the project soon, including the new Process Engine, that you can get more details in the first video, and after that if you want to work over your ideas, the project will be open to everybody make it greather.

1 Like