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_id | Org Id of desk; fetched from client |
app_install_id | {{sigmaInstallId}} |
encapiKey | {{enCapApiKey}} |
sigma execution domain | To 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.
https://db863857-d20d-4bfd-a681-c6c1230bb352.sigmaexecution.com/workspace/invokefunction?sigma_app_uuid=9e242b70-fe02-4944-b69b-823fb785ffd7&sigma_function_uuid=e9fbe975-1186-456f-b910-533453992c9c&sigma_function_version=2&integ_scope_id=portal 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
result=Map();
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");
sigma_execution_domain=data.get("sigma_execution_domain");
appVersion = data.get("version");
installationId = data.get("service_app_id");
encapiKey = zoho.encryption.urlEncode(encapiKey);
serviceData=data.get("service_data");
info data;
info encapiKey;
invokeSigmaFunction = invokeUrl
[
url :"https://"+sigma_execution_domain+"/workspace/invokefunction?sigma_function_uuid=70a6dd7c-772d-4a94-becf-438043379500&
sigma_function_version=2&integ_scope_id="+scopeId+"&app_install_id="+appId+"&custom_response=true&auth_type=apikey&encapiKey="+encapiKey
type : POST
parameters : data +""
];
info invokeSigmaFunction ;