Code Blocks

The Code Blocks feature enables FintechOS developers to insert predefined blocks of code into attributes of type After generate JS.

Code blocks are designed to be extensible and configurable. You can define your own code blocks and configure them based on your needs.

NOTE 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 do some changes in a code block to fulfill your needs (attributes, etc.). Within a code block you can call existing script libraries.

Code blocks are grouped per categories to help you easily spot the one that you want to use. To add code blocks, make sure that you have categories defined.

Step 1: Add categories

Categories help you group code blocks.

To add a code block category:

  1. From the menu, click ADMIN > Option Sets. The Option Sets List page appears.
  2. Search for the CodeBlocksCategories option set. You can do a partial Name or Display Name search by ''categories', or an exact Name match search by 'CodeBlocksCategories' or an exact Display Name match search by 'Code Blocks Categories'.
  3. Double-click on search result. The Edit Option Set page appears.
  4. Click the Insert button at the top of the OptionsetItems section. The Add OptionSetItem page appears.
  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. At the top -right corner of the page, click the Save and close icon to save the category. Add as many categories as best suit your needs. They are displayed in the OptionsetItems section.

Now you can add code blocks.

Step 2: Add code blocks

To add a code block:

  1. From the main menu, click Advanced > Code Blocks. The Add Code Block page appears.
  2. Fill-in the following fields:
  3. Field

    Description

    Name

    The category name used by the system. The field is mandatory

    Display Name

    The category name to be displayed in the user interface. The field is mandatory

    Usage Location The place where the code block will be available: Client Side or Server Side. The field is mandatory
    Documentation If you have the code block documented, provide the URL to the documentation.
    Category The category to which the code block will belong to. The field is mandatory.

    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 in After generate JS when using code blocks. The field is mandatory.

  4. At the top-right corner of the page, click the Save and close icon to save the code block. Add as many code blocks as you need to increase efficiency.

You can now start using code blocks

Step 3: Use code blocks

You can use code blocks in attributes of type After generate JS on forms (Advanced tab) or in the Advanced Code Editor.

To insert a code block in an After generate JS field:

  1. Place the cursor inside the desired After generate JS, right click and from the contextual menu click Insert Code Block.
  2. The Insert Code Block page appears.
  3. Click on categories and which one contains the code block you want to use.
  4. Double click on the desired code block or click on it then click the Insert code button. 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 as best suit your needs.