Functions | Online help | Zoho Sigma

Functions

Functions are the building blocks for developing an extension. They come handy for all server side customization. Sigma executes functions without additional infrastructure cost. External function calls can be done using rest APIs. You have to generate an API token to call functions outside Sigma. 

Sigma uses Deluge for building functions. Deluge script builder provides a drag-and-drop user interface which helps in creating functions quickly. Build anything from simple methods like sending an email notification to complex recursive functions using the editor. Click here to know more about writing functions in Deluge. 

Create a function

Let’s build a function to send an email notification

  1. Navigate to  Functions module and click  New Function  at the top right corner. 
  2. Enter a function name and give a description. 
  3. Click Create .
  4. Select a Return Type in the dropdown. Sigma supports Void and String return types.
    1. For email function we can select Void. 
  5. Drag and drop the send mail function under the  Notifications section in the left panel. 
  6. Specify the from and to addresses, email subject, and the message.  
  7. Click Save


Associate a function to an extension

Write a function and reuse it across your extensions wherever you require. You can associate a function to multiple extensions.    
  1. Navigate to Extensions , hover over your extension and click .
  2. Go to the Functions tab and click Associate Function .
  3. Select a Function Name from the drop-down.
  4. Select the Function Version you want to associate.
  5. Click Associate .
Your function will be associated with the extension. 



Execute associated functions

Associated functions can be executed with sample argument values.
  1. Navigate to Extensions , hover over your extension and click  .
  2. Go to the Functions tab and click on the function you would like to execute.
  3. Select the Portal in which you want to execute the function.
  4. Click on the Add Arguments button to configure sample arguments.
  5. Select argument IDs from the left dropdown and associate values to it.
    1. Click + to add more arguments.
  6. Select the Return Type as Void or String.
  7. Once all arguments are configured, click Save &  Execute.
This way, you can test your functions in extensions. 

 
Note
  1. The argument AppConfig will only be available for extension life cycle events.
  2. Function drafts can be edited and executed.
  3. Published functions can only be executed and cannot be edited. 

Update function versions associated to extensions

Every time a change is performed and saved in a function, it gets saved as a new version. These versions can be updated in extensions that are already associated with functions. To update the version,
  1. Navigate to Extensions , hover over your extension and click  .
  2. Go to the Functions tab and select the Version dropdown corresponding to the function you want to update.
  3. Select the required version from the dropdown.
 
Note
  1. If a function is associated with triggers, its version cannot be updated in the extension.
  2. A draft function associated with an extension can be updated to other function versions. However, once a function version is associated to an extension, it cannot be updated with a function draft.  

Disassociate function from an extension

In case you do not want the function to be associated with an extension, you can disassociate the same using this option.
  1. Navigate to Extension, hover over your extension and click  .
  2. Go to the Functions tab.
  3. Click  (...)  beside the corresponding function.
  4. Click  Disassociate.


Publish a function  

When you create a new function in Sigma and save, it gets saved as a Draft. To publish the function that you have created,
  1. Navigate to  Functions , hover over the function that you would like to publish.
  2. Click  (...)  beside the respective function.
  3. Select  Publish.             


Create Draft

Create Draft option lets you create a draft of a new version of a published function. In case you would like to add new enhancements to your extension, updating the function is important. With the  Create Draft  option, you can make changes to the function and save it as a draft.
  1. Navigate to  Functions , hover over the function for which you would like to create draft.
  2. Click  (...)  beside the respective function.
  3. Select  Create Draft


Create Draft option gets displayed only when the existing draft is published. 

Version 

Within this option, you can find all the versions of the functions created, along with the created time and status.
  1. Navigate to  Functions , hover over the extension for which you would like to view the version details.
  2. Click  (...)  beside the respective function.
  3. Select  Version


Delete a function    

  1. Navigate to Functions , hover over the function you would like to delete.
  2. Click (...)  beside the respective function.
  3. Click Delete .

Deleting the function will not be allowed if the function is associated with a trigger. Disassociate the function from the trigger to delete the function.