Skip to main content
Skip table of contents

Code Blocks

Overview

This is your golang code block where you can write your own custom code which
can be later used in your applications.

Code Blocks

This is your golang code block where you can write your own custom code which
can be later used in your applications.
Each code block is essentially a public function, which can have multiple inputs, but can return only 2 outputs - of which one represents your custom output value, and the other represents any error that occurred during the function execution.
You can add as many functions as you want to the code block, but every code block should belong to the custom package and have one public function with the same name as the code block in pascal casing.

Code blocks involve injecting custom code into your applications. Please proceed with caution, and do not add random or untested code without verification.

Code Block Configuration

In this section, we will see how to add,edit & delete code block.

Create Code Blocks

You can find code blocks under the Explorer panel.

Hovering over code block reveals a (+) icon. Clicking on this icon opens a text field to type code block name. Here you need to type the name of the code block. After entering the name, you must hit the “Enter“ key on the Keyboard. The changes can be saved by using the “Save changes” button under File.

image-20240526-211858.png

Fig 1: Create Code Block by clicking on + Icon

image-20240526-212251.png

Fig 2: Code Blocks Created

The file name even to a Code block will be same as the name of the function. The only difference is that the name of the function in the code block will be in lowercase letters with the first letter in Uppercase.

After creating a code block, a default code will be created in the canvas which user can customize according to his requirements. A default code will be generated as follows: -

package custom

func Fact() (interface{}, error) {
// Your code goes here

CODE
return nil, nil

}

where custom is the name of the package, Fact() is the function name and interface{} and error are the type of data returned by code block. You can write your own code under this and click on Save changes from File to Save your code.

https://youtu.be/RfvDDdSuUdQ?si=uZGzKsW69XJfAQeo

Edit Code Blocks

Hovering over the code block name reveals pencil icon next to it. You can edit code block name by clicking on the pencil icon next to code block name under explorer section. The text box becomes editable and you can edit the name by typing in and then press enter key to save the name.

You can also edit the name by renaming/entering Name in the Properties section in the right side of the canvas and then click on Save Changes from File menu.

image-20240526-212556.png

Fig 3: Code Blocks Edit icon

Delete Code Blocks

You can delete code block by clicking on the delete icon next to code block name under explorer section.

After clicking delete icon, a pop up appears to confirm the delete of your code block. Click on Ok to delete the code block or Click Cancel to close the pop-up. On clicking Ok Your code block will be deleted successfully. All data associated with the code block will be permanantly erased.

image-20240526-212711.png

Fig 4: Code Blocks Delete icon

image-20240526-212836.png

Fig 5: Code Blocks Delete Pop-up

https://youtu.be/ZTR9ZUbIU9M?si=2BSpBzNqFpgNErIr

Code Blocks Properties Section

On the right side of the canvas, properties panel is displayed which consists of the following fields: -

Name- This is the name of the code block which is given while creation. You can also edit the name by renaming/entering Name in the Properties section in the right side of the canvas and then click on Save Changes from File menu.

Language- This is the language in which the code needs to be written. You need to write the code in golang language.

Input Parameters- Input parameter is a variable that you need to pass to the code block. On clicking (+) icon a pop-up window opens to enter the unique parameter variable name and the Type of the parameter. After entering variable/data you want to send as input to code block click on Save button. The parameter will be visible under the Input parameters section. You can edit the input parameters by clicking on pencil icon next added parameter. A pop-up window appears and you can edit/change the name or type and click Save button. You can delete the input parameters by clicking on delete icon next to added parameters. On clicking delete icon the parameter will be deleted permanently.

Publish Section- In this section, user can publish code blocks so that they are usable throughout all applications in the portal. After publishing it gets available to any user. Published code blocks must have an open-source usage license attached to them. You can publish by selecting license like Apache 2.0 License, MIT License , Zero Clause BSD License etc. and click on Publish button. Success message is displayed as “Code block published successfully “. You can also unpublish a code block by clicking on Unpublish button. On doing so success message will be displayed as “Code block unpublished “.

image-20240526-212455.png

Fig 6: Properties Section

https://youtu.be/7s0oYZx6VsE?si=EDUaggOF4dkOumGg

Code Block step configuration with example

https://youtu.be/Ql80FtYas14?si=OX_rHXXBLAC26CVO

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.