To create a function
- Go to Setup > Developer Space > Functions.
- In the Functions page, click + Create New Function.
- Choose the place where the function is meant to be added.
- Click Next.
- In the Create Function page, do the following:
- Give a Name and description(optional) for the function.
- Click Edit Arguments.
- Set the arguments to be used in the script, with field name or custom value in CRM module.
- Write your required function in the Deluge Script Editor.
- Click Save & Execute Script to validate your code.
- Click Save.
- Give a Name and description(optional) for the function.
- Click Save.
The function will be listed in the List View of the Functions page.
Calling Functions using REST APIs
A
function lets you have additional functionalities and features in your
CRM apart from the conventional features. Functions needs a trigger to
call it. The trigger could be in the form of a workflow, blueprint,
related list or through the click of a button.
If the function needs to be triggered without employing these methods or from external sources, you can create standalone functions and make them available as API calls. Triggering functions through REST APIs which gives the flexibility to trigger it from anywhere inside Zoho CRM or from any third party application.
Sample function as an API call
A form which automatically generates a lead in your CRM with the information given as input in the form.
Step 1
Create a standalone function with the following code.
Note
Step 2
To make function available as an API
- Go to Setup > Developer Space > Functions.
- Click the Settings icon for the corresponding function which needs to be made an API.
- Click REST API.
- Set the API name for the custom function.
- Enable OAuth2.0 and the API key sliders.
- Click Save.
Note
- Select OAuth2.0 for sharing the function as an API within your organization.
- Select API Key for the sharing the function with any 3rd party and enable it to be used by anyone.
Step 3
The sample here is shown as a form created using Zoho Creator.
Create the form such that it has the fields "FirstName", "LastName",
"Company" and "Mobile". You can program the function to get executed
upon the click of Submit button.
The Result
Once the Submit button
is clicked, the function gets executed and the Lead is created in your
CRM. The lead has the details which was given within the form.
Functions in Postman
Functions
which are given as API calls can be tested using POSTMAN application.
However, there are a few things that you need to keep in mind when
executing a function in that app.
- The current supported methods for using a function as an API are GET and POST.
- In a POST request, under the "Body" section, select "form-data".
- Create a Key named "arguments" and the Value as the Input JSON object.
- The arguments can also be given in the URL as arguments={encoded_arguments}
- POST request - Arguments Limit
- In request URL - 5000 lines
- In body - 95000 lines (as JSON object)
- In request URL - 5000 lines
Sample arguments in "Body"
- {
- "First_Name":"Art",
- "Last_Name":"Clayton",
- "Company":"Zylker",
- "Mobile":"555-876-4367"
- }
Deploying Functions in Workflow Rules
To associate function to a workflow rule
- Go to Setup > Automation > Workflow Automation > Rules.
- In the Workflow Rules page, click the Create Rule.
- In the Create New Rule tab, specify workflow rule parameters.
- Under Instant Actions, select Function.
- In the Configure Function page, select a function from the Gallery, Functions (Created by users in your organization) or Write your Own using Deluge script.
- Click Functions (Created by users in your organization).
- Select the function to be triggered and click Configure.
- In the Configure Custom Function page, complete the following steps:
- Select the module to be associated.
- Under Argument Mapping section, map the argument with field name in CRM module.
- Click Save and Associate.
Now you can associate the gallery custom function with workflow rule.
- Select the module to be associated.
- Click Save in the Workflow rule page.
Now, your customized function is associated with workflow rule. When the workflow rule is triggered, custom function will be automatically executed.
See Also - Integrate a function to a Schedule, Custom Button and Related List.
To test the function integration
- Add test data in Zoho CRM according to your workflow rule criteria.
- Check for the data received from Zoho CRM via function, in your application.
- Modify your function code in Zoho CRM, if data is not received or if there is a data mismatch.
- Continue this test until you obtain the required data from Zoho CRM to your Application.
Important Notes
- You can associate up to 6 (1 Instant Action and 5 Time-Based Actions) functions per workflow rule.
- You can execute only 5000 lines (Statements) in a single function call.
- You can transfer data for a maximum of 10 CRM fields from Zoho CRM to third-party applications using function.
- You can retrieve data from other Apps to Zoho CRM using function.
- You must update the API ticket regularly according to limits in third-party applications.
- You
will not receive any email notification, if the function integration
stopped functioning due to any issue in a third-party API.
- If
there is any failure while connecting to Zoho Creator service, function
will send the second notification after 15 min. Thereafter, the system
will not send any notifications for that particular workflow trigger.
Errors returned from Zoho Creator are shown under Reason for Failures
section.
- If you exceed the maximum count per day, the system
will not send remaining function notifications to third-party
applications and will notify the failure to Administrator.
- Zoho CRM will the send the data in following standard format for Date and Date Time fields to third-party applications:
- Date: yyyy-MM-dd
- Date Time: yyyy-MM-dd hh:mm
- Date: yyyy-MM-dd
- Limits for Custom Functions:
- Calls per Day - 10000 calls/day or 200 calls per user license for the org. (whichever is lower)
- Integration Tasks - 25000 Zoho API calls/day using deluge.
- Get Data & Post Data - 25000 calls/day (totally)
- Send Email - 1000 emails/day
- Calls per Day - 10000 calls/day or 200 calls per user license for the org. (whichever is lower)
Refer Error Codes
When the execution of function fails, one of the following error messages will be displayed in Zoho CRM:
HTTP Status Codes
- 400 Bad Request - Often missing a required parameter.
- 401 Unauthorized - No valid API key provided.
- 402 Request Failed - Parameters were valid but request failed.
- 404 Not Found - The requested item doesn't exist.
- 500, 502, 503, 504 Server errors - Error in the third-party application.
- Error Code 1 - Temporarily not able to connect to the API server. Check API server logs, firewalls settings for requests sent from CRM.
Custom Errors
- Internal process failure - When the function is not executed due to errors in processing of the script.
- Day limit reached - When the company has reached the maximum limit for the day.
- Deluge Script - When the execution of workflow triggers fail due to errors in Deluge Script.