Function Execution

A sigma function can be executed in the following ways:


How functions are used in widgets

To execute function via widget, we need to call sigma function's Execution URL from the widget. To call this URL you must provide the values for mandatory parameters as merge fields  in Execution URL, as given below:

Mandatory Parameters

Values ad Merge Field

integ_scope_idOrg Id of desk; fetched from client
sigma execution domainTo be fetched from App Meta of extension's widget

Merge Field  acts as a placeholder that temporarily holds the reference data to insert the actual data.

Sample Execution URL: 

This is the sample URL built to execute a function via widget. Now this URL has to be called via Request Method. id&app_install_id={{sigmaInstallId}}&custom_response=true&auth_type=apikey&encapiKey={{enCapApiKey}}

*extensionVersion, sigmainstalid, and encapapikey
will act as merge fields, whose values will be fetched dynamically on execution. portal id should be manually given in the URL, it can be fetched using portal object.


How functions are used in resource

Let's look at how the function is executed via Resources (for example: Webhooks). You know that to create webhook on the event of extension_installation, you must specify the webhook details in resources.json file. In that resource.json file, to execute the functions via resources, you must provide the Execution URL (i.e., URL copied from functions in Extension Details page of Sigma) in the URL attribute.

Now, the function will be executed via resource while installing the extension and the created resource will be displayed as shown below along with the details like Name, Domain (URL), Module-Event, Created By, and Status based on the inputs given in resource.json file.

Note: The Mandatory parameters parameters of executable URL will be automatically fetched and sigma execution domain will also be automatically pre-fixed.


How functions are executed in another function

To execute a function via another function, provide the values for mandatory parameters of execution URL based on input Json fetched from another function and make the API call, or you can build using the Deluge script. The sample code given below depicts how a function is executed from another function.

Sample Code

deskDomain =  data.get("service_domain");
appId = data.get("app_install_id");
scopeId = data.get("integ_scope_id");
encapiKey = data.get("encapiKey");
sigmaDomain = data.get("sigma_domain");
appVersion = data.get("version");
installationId = data.get("service_app_id");
encapiKey = zoho.encryption.urlEncode(encapiKey);
info data;
info encapiKey;

invokeSigmaFunction = invokeUrl
url :"https://"+sigma_execution_domain+"/workspace/invokefunction?sigma_function_uuid=70a6dd7c-772d-4a94-becf-438043379500&
type : POST
parameters : data +""
info invokeSigmaFunction ;