Skip to content

Lambda Plugins λ

Lambda plugins (also known as scripts) are used to alter the behaviour of the server without the bloat and the complexity of full blown plugins.

Under the hood lamba plugins are (as the name implies) still implemented using plugins but the process is automated and hassle free.

Lambda plugins can be easily created using ONO WMS, they must be written in JavaScript and offer great flexibility and power.

Features

  • Altering of messages exchanged between UI clients and the server
  • Ability to use any npm package
  • Full read & write access to the ONO database
  • File system storage space
  • Aync/Await support
  • Time based scripts

Danger

With great power comes great responsibility. Try not to mess up your database. Incorrect database data can lead to crashes both software and hardware.

Creating your first lambda plugin

  1. Open WMS and click on Advanced
  2. Click on Scripts
  3. Click on the + button to add a new script
  4. Fill in the details about your script
    • Name: The name by which you'll identify this script. The script name must not contains spaces and must otherwise be a correct Linux directory name.
    • Collection: You can optionally group your scripts in collections. If you don't want to, you can leave this field empty.
    • Dependencies: If your script depends on external NPM packages you can type their name in this field and press the enter key to mark them as required. You'll se a little tag appearing. If you later changed your mind you can click on the red cross on the tag to remove the dependency.
    • Event: The event that will trigger the execution of this script. For more info please refer to Plugins/Reference.
  5. Write the code that will be execute when the event is triggered and then click on the save button.

In this little example we've created a script called AddDateToProduct in collection ProductScripts that has no dependencies and is triggered by the BeforeCreateProductEvent.

This event is fired when a new box is inserted in the wharehouse. Our code will prepend the date of creation to its unique code. Therefore a box that gets inserted with code GK22 will become 1/4/2020 - GK22. Let's test it out.

Looks like it worked!