Create a code snippet

In this topic, you learn how to create a code snippet that you can reuse in other services.

Prerequisites

  • There are no prerequisites.

Procedure

  1. On the cockpit, go to Development and select Code Snippets.

    Result: You can see a list of existing code snippets.

  2. Select Add.

    Result: A new window opens. You see the General tab.

  3. Enter a Name for your snippet. Choose a name that gives a clear indication of the content.

  4. Enter a Description of what the snippet is about.

  5. Select a Grouping from the drop-down menu the snippet belongs to. Or define a new Group by typing the new Group name in the Grouping input.

    In the App_Designer and in the Script Editor, you find your created code snippets under Custom when you try to insert a new snippet.
  6. Select the Development Package it should belong to.

  7. Select the checkboxes Use in App Designer and Use in Script Editor to decide if your snippet should be available in the App Designer, the Script Editor, or in both.

  8. Select the Editor tab.

    Result: The editor tab opens.

  9. Write your code here.

    Select Import to import existing code into the editor. The file must be in .planet9 format.
  10. Select Save. Result: Your snippet is saved with the current settings and is added to the library in the App Designer and in the Script Editor.

Results

  • You have created a code snippet that can be used in the Script Editor or in the App Designer.