Code Blocks

Code Blocks are predefined code templates you can insert in your scripts. Code blocks are designed to be extensible and configurable. You can define your own code blocks and configure them based on your needs.

Do not confuse script libraries with code blocks. Unlike the Client Script Libraries and Server Automation Script Libraries which you call directly in scripts, you need to adapt a code block to fulfill your needs (attributes, etc.). However, you can call existing script libraries in your code blocks.

Code blocks are grouped into categories to help you easily filter the relevant blocks.

Define Code Blocks Categories

Categories help you group code blocks.

To add a code block category:

  1. In FintechOS Studio, go to Main Menu > Admin > Option Sets.
  2. Search for the CodeBlocksCategories option set (you can filter either the CodeBlocksCategories name or the Code Blocks Categories display name).
  3. Double-click the option set.
  4. Click Insert.
  5. In the Name field, type a name that will be used by the system and in the Display Name field, type the name that will be displayed in the user interface.
  6. Click Save and close.

Add as many categories as best suit your needs. As you create categories, they are displayed in the Option Set Items section.

Add Code Blocks

  1. In FintechOS Studio, go to Main Menu > Advanced > Code Blocks.
  2. Click Insert.
  3. In the Add Code Block page, fill-in the following fields:
  4. Field Description
    Name The category name used by the system.
    Display Name The category name to be displayed in the user interface.
    Usage Location The place where the code block will be available: Client Side or Server Side.
    Documentation If you have the code block documented, provide the URL to the documentation.
    Category The categories to which the code block belongs to.
    Description Provide a brief description of the code block to help others easily identify the scope of the code block.
    Code JavaScript code which will be inserted when using the code block.

  5. Click Save and close.

Add as many code blocks as you need.

Use Code Blocks

You can use code blocks in any code editor (either the Advanced Code Editor or regular editors):

  1. In your code editor, right click and, from the context menu, select Insert Code Block.
  2. The Insert Code Block page appears.
  3. Filter the code blocks by selecting the relevant category.
  4. Double click on the desired code block or click it and select Insert code. The code from the selected code block is added on a new line at the cursor position in the editor.
  5. Modify the inserted code template based on your requirements.