Zoho FSM | Functions

Functions

‌Custom functions are used for defining custom business logic, formulating processes, and automating repetitive tasks. They are used for manipulating details of one or more FSM modules through record creation, updation or deletion. They are also used for implementing functionalities with the use of third-party applications. Custom functions are used by associating them with workflows. They are written using Deluge Scripting Language.

Custom functions can be used primarily in two ways:
  1. For automating basic actions like sending emails
  2. For accessing data from Zoho or third-party services
Permission RequiredManage Automation
- Find out the Edition-specific limits for Custom Functions.

‌Create a Custom Function

You can use functions for automating routine activities.  For example, the sendmail task enables you to send notifications. 

To create a function that will notify the customer by email when a new request is created for them:
  1. Navigate to Setup > Automation > Functions.
    Only users with the profile Administrator will have this option.
  2. Click Create Function.



  3. ‌In the Create Function overlay, do the following:
    1. Enter the Function Name as SendNotification.
    2. Select Requests as the Module for which you want to trigger the custom function.
    3. In the Deluge Script Editor, write the below script for the custom function.


        void SendUpdate(Map request , Map organization , Map user){
        
        //Get customer name
        customer = request.get("Contact");
        custName = customer.get("name");
        //Get customer email
        email = request.get("Email");
        //Get request name
        reqName = request.get("Name");
        //Send notification
        sendmail
        [
      from :zoho.loginuserid
      to :email
      subject :"New Request"
      message :"Hi " + custName + "," + "<br>" + "A new Request " + reqName + " has been created for you." + "<br>" + "Thanks," + "<br>" + "Support Team"
        ]

        }
       


    4. Click Save.

To test the function, do the following:
  1. In the Deluge Script Editor, click Save & Execute.
  2. In the Execute Function pop-up, enter a Request record ID or click Click here to get the list to obtain the list of available Request IDs.
  3. Select a Request ID and click Execute.



    The results of the function will be displayed in the console. You can use this to test and debug your custom functions.


To use this function, you need to associate this function with a workflow.

Data Manipulation using Custom Functions

You can use custom functions for accessing data from Zoho or third-party services. You can use the Deluge tasks for data manipulation to do so. For example, the task for creating records (zoho.fsm.createRecord) in FSM.

There are two ways in which these tasks can be used:
  1. Using a System Connection. E.g. zoho.fsm.createRecord(<module>, <KEY-VALUE>);
  2. Using a Connection of a Service (Default/Custom). E.g. zoho.fsm.createRecord(<module>, <dataMap>, <optionalDataMap>, <connection>);
What is a Connection?
There are some services that cannot be integrated directly with Zoho FSM. In these cases, you can use a connection to expand FSM's third-party support. Connection uses OAuth 2.0 protocol to facilitate this integration.

There are three types of connections:
  1. System Connection: The connection used by the built-in integration task, for accessing the data from FSM and other Zoho services (CRM, Projects, Books, etc). Individual internal connections will be created for individual Zoho integration tasks.
  2. Connection using Default Services: You can choose from the already available list of services, provide your credentials, and establish a connection.
  3. Connection using Custom Services: If the desired service is not available in the default services list, you can configure it on your own and connect to it.

Create a Function using the System Connection

The system connection used for the FSM data manipulation tasks is listed under System Connections at Setup > Automation > Connections. Ensure that the status of the connection is Connected. The green dot [] indicates that the connection is Connected.



To write the function that inserts a new record in the Requests module, do the following:

  1. Navigate to Setup > Automation > Functions.
  2. Click Create Function.



  3. In the Create Function overlay, do the following:
    1. Enter the Function Name as CreateRequests.
    2. Select Requests as the Module for which you want to trigger the custom function.
    3. From the tasks tray on the left in the Deluge Script Editor, drag and drop the Deluge task you want to use. In our case it is create record.
    4. Write the below script for the custom function.


        void CreateRequests(Map request , Map organization , Map user){

        newRecordInfo = Map();
        newRecordInfo.put("Summary","Sample");
        newRecordInfo.put("Status","New");
        newRecordInfo.put("Contact","1011000000141106");
        newRecordInfo.put("Territory","1011000000139148");

        serviceAddress = Map();
        serviceAddress.put("id", "1011000000141109");
        serviceAddress.put("Service_Street_1", "10 Oak St");
        serviceAddress.put("Service_Street_2", null);
        serviceAddress.put("Service_City", "Oconee");
        serviceAddress.put("Service_State", "Illinois");
        serviceAddress.put("Service_Country", "United States");
        serviceAddress.put("Service_Zip_Code", "62553");
        serviceAddress.put("Service_Latitude", "39.287425");
        serviceAddress.put("Service_Longitude", "-89.108759");
        serviceAddress.put("Service_Address_Name", "Service Address");

        billingAddress = Map();
        billingAddress.put("id", "1011000000141108");
        billingAddress.put("Billing_Street_1", "Locust St");
        billingAddress.put("Billing_Street_2", null);
        billingAddress.put("Billing_City", "Oconee");
        billingAddress.put("Billing_State", "Illinois");
        billingAddress.put("Billing_Country", "United States");
        billingAddress.put("Billing_Zip_Code", "62553");
        billingAddress.put("Billing_Latitude", "39.286597");
        billingAddress.put("Billing_Longitude", "-89.107787");
        billingAddress.put("Billing_Address_Name", "Billing Address");

        newRecordInfo.put("Service_Address", serviceAddress);
        newRecordInfo.put("Billing_Address", billingAddress);
        resp = zoho.fsm.createRecord("Requests", newRecordInfo);
        info resp;

        }

    5. Click Save
To test the function, do the following:
  1. In the Deluge Script Editor, click Save & Execute.
  2. In the Execute Function pop-up, enter a Request record ID or click Click here to get the list to obtain the list of available Request IDs.
  3. Select a Request ID and click Execute.



    A new Request record has been created and you can view the details of the record in the console.


To use this function, you need to associate this function with a workflow.

Create a Function using the Connection of a Default Service

Following are the steps to create a function that inserts a new record in the Requests module.
  1. Create a Connection for a Default Service (Zoho FSM)
  2. Write the function
Create a Connection for a Default Service (Zoho FSM)
  1. Navigate to Setup > Automation > Connections > My Connections.
    Only users with the profile Administrator will have this option.
  2. Click Create Connection.
  3. Select the Default Services tab and click on the service to which you want to connect your Zoho Service. In our case, we need to select Zoho FSM.



  4. Enter a Connection Name.
  5. Choose Scopes.
    The following scopes are available for FSM. Select the appropriate scopes as per your requirements.

     Scope
    Description
    ZohoFSM.modules.custom.READ

    ZohoFSM.modules.contacts.READ

    ZohoFSM.modules.accounts.READ

    ZohoFSM.modules.Requests.READ

    ZohoFSM.modules.Estimates.READ

    ZohoFSM.modules.WorkOrders.READ
    Used to retrieve records. Will be used in the following tasks:

    zoho.fsm.getRecords(<module>, <page>, <perPage>, <optionalDataMap>, <connection>);

    zoho.fsm.getRecordById(<module>, <id>, <optionalDataMap>, <connection>);

    zoho.fsm.getRelatedRecords(<relationName>, <parentModuleName>, <id>, <page>, <perPage>, <optionalDataMap>, <connection>);
    ZohoFSM.modules.custom.CREATE

    ZohoFSM.modules.contacts.CREATE

    ZohoFSM.modules.accounts.CREATE

    ZohoFSM.modules.Requests.CREATE

    ZohoFSM.modules.Estimates.CREATE

    ZohoFSM.modules.WorkOrders.CREATE
    Used to create records. Will be used in the following tasks:

    zoho.fsm.createRecord(<module>, <dataMap>, <optionalDataMap>, <connection>);





    ZohoFSM.modules.custom.UPDATE

    ZohoFSM.modules.contacts.UPDATE

    ZohoFSM.modules.accounts.UPDATE

    ZohoFSM.modules.Requests.UPDATE

    ZohoFSM.modules.Estimates.UPDATE

    ZohoFSM.modules.WorkOrders.UPDATE
    Used to edit records. Will be used in the following tasks:

    zoho.fsm.updateRecord(<module>, <id>, <dataMap>, <optionalDataMap>, <connection>);







  6. Click Create and Connect.
  7. Click Accept in the permissions page.
    The connection is created. The Link Name will be used as an argument in the task zoho.fsm.createRecord.


Write the function
  1. Navigate to Setup > Automation > Functions.
  2. Click Create Function.



  3. In the Create Function overlay, do the following:
    1. Enter the Function Name as CreateRequests.
    2. Select Requests as the Module for which you want to trigger the custom function.
    3. Write the below script for the custom function:


        void CreateRequests(Map request , Map organization , Map user){

        newRecordInfo = Map();
        newRecordInfo.put("Summary","Sample");
        newRecordInfo.put("Status","New");
        newRecordInfo.put("Contact","1011000000141106");
        newRecordInfo.put("Territory","1011000000139148");
       
        serviceAddress = Map();
        serviceAddress.put("id","1011000000141109");
        serviceAddress.put("Service_Street_1","10 Oak St");
        serviceAddress.put("Service_Street_2",null);
        serviceAddress.put("Service_City","Oconee");
        serviceAddress.put("Service_State","Illinois");
        serviceAddress.put("Service_Country","United States");
        serviceAddress.put("Service_Zip_Code","62553");
        serviceAddress.put("Service_Latitude","39.287425");
        serviceAddress.put("Service_Longitude","-89.108759");
        serviceAddress.put("Service_Address_Name","Service Address");

        billingAddress = Map();
        billingAddress.put("id","1011000000141108");
        billingAddress.put("Billing_Street_1","Locust St");
        billingAddress.put("Billing_Street_2",null);
        billingAddress.put("Billing_City","Oconee");
        billingAddress.put("Billing_State","Illinois");
        billingAddress.put("Billing_Country","United States");
        billingAddress.put("Billing_Zip_Code","62553");
        billingAddress.put("Billing_Latitude","39.286597");
        billingAddress.put("Billing_Longitude","-89.107787");
        billingAddress.put("Billing_Address_Name","Billing Address");

        newRecordInfo.put("Service_Address",serviceAddress);
        newRecordInfo.put("Billing_Address",billingAddress);
        resp = zoho.fsm.createRecord("Requests", newRecordInfo, Map(), "fsmconnection");
        info resp;

        }


    4. Click Save.
To test the function, do the following:
  1. In the Deluge Script Editor, click Save & Execute.
  2. In the Execute Function pop-up, enter a Request record ID or click Click here to get the list to obtain the list of available Request IDs.
  3. Select a Request ID and click Execute.



    A new Request record has been created and you can view the details of the record in the console.


To use this function, you need to associate this function with a workflow.

Understanding the CreateRecord Task

Let's look at how the zoho.fsm.createRecord is used. The syntax for the task is given below.

Method Used
Syntax
 Using the Internal Connection
 <Response> = zoho.fsm.createRecord(<module>, <KEY-VALUE>); 
 Using the Connection of a Service (Default/Custom)
 <Response> = zoho.fsm.createRecord(<module>, <KEY-VALUE>, <optionalDataMap>, <connection>);

where,
<Response> is the task response returned as a Map.
<module> specify the API name of the module from which you want to fetch records
<KEY-VALUE> is a map with details of the record that needs to be inserted into the module.
<optionalDataMap> is a map parameter to pass any additional values
<connection> is the connection created for Zoho FSM
 
The <module> argument
 The API name of the module, i.e. Requests needs to be used.
 
The <KEY-VALUE> argument
 The details of the fields and its values required for constructing the <KEY-VALUE> map can be viewed by clicking the Map argument (request) of the module.



The <optionalDataMap> argument
In case you need to pass any additional data you can use this argument else pass an empty map, Map().
 
The <connection> argument
The value to be used for the <connection> argument is the Link Name of the connection created for FSM. To view this detail, click the connection.


Associate with Workflow Rules

You can either associate an existing function to the workflow or create a new function and associate it to the workflow. The module for which the workflow and function is created should be the same. If you create a workflow for the Requests module, then the new function that you create or the existing function you can associate should also be of the Requests module.


Manage Custom Functions

You can edit, delete, or clone a function.


Function Failures

When a workflow is triggered, its associated function gets executed. The function might fail when executed on some records. The details of such errors and the records that caused it can be viewed under the Function Failures tab at Setup > Automation > Functions.


    Access your files securely from anywhere

      Zoho CRM Training Programs

      Learn how to use the best tools for sales force automation and better customer engagement from Zoho's implementation specialists.

      Zoho CRM Training
        Redefine the way you work
        with Zoho Workplace

          Zoho DataPrep Personalized Demo

          If you'd like a personalized walk-through of our data preparation tool, please request a demo and we'll be happy to show you how to get the best out of Zoho DataPrep.

          Zoho CRM Training

            Create, share, and deliver

            beautiful slides from anywhere.

            Get Started Now


              Zoho Sign now offers specialized one-on-one training for both administrators and developers.

              BOOK A SESSION





                          Quick Links Workflow Automation Data Collection
                          Web Forms Enterprise Begin Data Collection
                          Interactive Forms Workplace Data Collection App
                          CRM Forms Customer Service Accessible Forms
                          Digital Forms Marketing Forms for Small Business
                          HTML Forms Education Forms for Enterprise
                          Contact Forms E-commerce Forms for any business
                          Lead Generation Forms Healthcare Forms for Startups
                          Wordpress Forms Customer onboarding Order Forms for Small Business
                          No Code Forms Construction RSVP tool for holidays
                          Free Forms Travel
                          Prefill Forms Non-Profit

                          Intake Forms Legal
                          Mobile App
                          Form Designer HR
                          Mobile Forms
                          Card Forms Food Offline Forms
                          Assign Forms Photography
                          Mobile Forms Features
                          Translate Forms Real Estate Kiosk in Mobile Forms
                          Electronic Forms

                          Notification Emails for Forms Alternatives Security & Compliance
                          Holiday Forms Google Forms alternative  GDPR
                          Form to PDF Jotform alternative HIPAA Forms
                          Email Forms
                          Encrypted Forms
                          Embeddable Forms
                          Secure Forms
                          Drag and Drop form builder
                          WCAG


                                            You are currently viewing the help pages of Qntrl’s earlier version. Click here to view our latest version—Qntrl 3.0's help articles.




                                                Manage your brands on social media

                                                  Zoho Desk Resources

                                                  • Desk Community Learning Series


                                                  • Digest


                                                  • Functions


                                                  • Meetups


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner


                                                  • Word of the Day


                                                    Zoho Marketing Automation

                                                      Zoho Sheet Resources

                                                       

                                                          Zoho Forms Resources


                                                            Secure your business
                                                            communication with Zoho Mail


                                                            Mail on the move with
                                                            Zoho Mail mobile application

                                                              Stay on top of your schedule
                                                              at all times


                                                              Carry your calendar with you
                                                              Anytime, anywhere




                                                                    Zoho Sign Resources

                                                                      Sign, Paperless!

                                                                      Sign and send business documents on the go!

                                                                      Get Started Now




                                                                              Zoho TeamInbox Resources



                                                                                      Zoho DataPrep Resources



                                                                                        Zoho DataPrep Demo

                                                                                        Get a personalized demo or POC

                                                                                        REGISTER NOW


                                                                                          Design. Discuss. Deliver.

                                                                                          Create visually engaging stories with Zoho Show.

                                                                                          Get Started Now









                                                                                                              • Related Articles

                                                                                                              • Standalone Functions

                                                                                                                Field service management will be at its optimal level when there is proper synergy between all the people and processes involved. Crucial data conveyed on time to the correct stakeholder is paramount in maintaining the KPIs. To this end, Zoho FSM ...
                                                                                                              • Audit Log

                                                                                                                The Audit log captures the activities performed within the Setup of your FSM organization. This audit log can be viewed at Setup > Data Administration > Audit Log. Click on an entry to see the details. Filters Any of the following filters can be ...
                                                                                                              • Integrate with QuickBooks

                                                                                                                QuickBooks is an accounting software. This help document details the steps to integrate QuickBooks with FSM. It broadly consists of the following: Create a connection for QuickBooks Create a custom function in FSM Create a connection for QuickBooks ...
                                                                                                              • Create an event in Zoho Calendar for a Service Appointment

                                                                                                                Use Case: Whenever a service appointment is dispatched in Zoho FSM, create an event in Zoho Calendar. Step 1: Create a custom function Step 2: Create a workflow rule Step 1: Create a custom function Add a custom function that will create an event in ...
                                                                                                              • Create a Work Order in Zoho FSM from a Sales Order in Zoho Books

                                                                                                                Use case: Whenever a Sales Order is created in Zoho Books, create a Work Order for it in Zoho FSM. Follow the steps below to implement this use case: Step 1: Create a connection for Zoho FSM in Zoho Books Step 2: Create a custom function in Zoho ...
                                                                                                                Wherever you are is as good as
                                                                                                                your workplace

                                                                                                                  Resources

                                                                                                                  Videos

                                                                                                                  Watch comprehensive videos on features and other important topics that will help you master Zoho CRM.



                                                                                                                  eBooks

                                                                                                                  Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho CRM.



                                                                                                                  Webinars

                                                                                                                  Sign up for our webinars and learn the Zoho CRM basics, from customization to sales force automation and more.



                                                                                                                  CRM Tips

                                                                                                                  Make the most of Zoho CRM with these useful tips.



                                                                                                                    Zoho Show Resources