Scripts

Memento allows adding the scripts to your libraries. You can customize an automated code that is going to be executed on a certain event. You can use two types of scripts — Triggers and Actions. Before going any further, learn more about Memento Database syntax, Triggers, and Actions examples.

To add a Script while creating or editing a Library, scroll down to find the Scripts option and tap on it. Now, press Add script to continue: choose the type of Script you want to add — Trigger, Action, or Shared. Make sure to check out the description of the script you are interested in below.

While creating a Trigger, you define the event that will run the script. If you chose this type of script, here is what you need to do after that:

  • Set a Name for this script
  • Choose an Event to define when this script is executed: the list offers numerous options to choose from
  • Pick the Phase for this Trigger: the choice will depend on the Event you have chosen in the previous step
  • Click Script field to input the code for your Trigger
  • Press Add library to import JavaScript libraries

Actions are activated once you press an icon on the toolbar of a chosen Library. If you chose this type of script, here is what you need to do after that:

  • Set the Name for this script
  • Choose a Place of action for this script
  • Click Script field to input the code for your Trigger
  • Press Add library to import JavaScript libraries
  • Tap on Add argument to define the values the user enters to be used inside the script

Shared scripts can be used in any Triggers within one library. As an example, if you have several Triggers that have a common code fragment, you can add it as a Shared script. If you chose this type of script, here is what you need to do after that:

  • Set the Name for this script
  • Click Script field to input the code for your Trigger
  • Press Add library to import JavaScript libraries

Press Create, and you’re good to go.

Once you have added the needed script(s), you can set Scripts permissions in the Scripts menu. When you’re done, click Create or Edit to go back to the previous menu, and press Save to keep the changes.

If you are using Scripts in your library, you may find the Button field type useful. This field permits assigning an action to it and performing it on click. Here is what you can customize for the Button field type while Creating or Editing the Library:

  • Define the Field name
  • Set the Action parameters: choose action Type (Open URL, Run script, or Share) and set additional info depending on the chosen Type
  • Choose how to Display this field in the Library
  • Add Dependencies if needed

Was this article helpful?

Related Articles