Zoho FSM | Standalone Functions

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 provides Standalone Functions that will help you in processing data in FSM when it is driven by external parameters. You can write functions that will cater to complex business requirements and expose the function as a REST API. Thus a standalone function can be used by Zoho FSM, other Zoho applications, and any third-party application.

Let's better understand the use of the standalone functions using an example. Consider a company Zylker Inc., that is in the business of selling and managing vending machines. They require information about the real-time stocks in vending machines in different locations so that they can restock on time. The IOT-enabled vending machines will be able to transmit such information through smart sensors. Zylker Inc. uses Zoho FSM and stores details of its vending machines in the Assets module. Each asset will have a boolean field called Restock Required. When the stock in an asset reaches the restock level, the value of Restock Required can be updated to true using a standalone function. Using this action as a trigger, a workflow can create a request to restock the asset. Thus, with minimal human intervention, and interaction, servicing for the vending machine is done proactively.

Permission Required:
  1. For creating: Manage Automation
  2. For executing: Function as REST API
- Find out the Edition-specific limits for Standalone Functions.

Supported Authorization Types
OAuth 2.0

Supported Request methods

Method

Scope

GET

ZohoFSM.functions.execute.READ

POST

ZohoFSM.functions.execute.CREATE


Function Parameter
The function has a Map parameter APIRequest. When you make the function call, APIRequest will contain the following details:
 

Name

Description

Body
Any input that is passed as a stream to the request can be fetched using the component body of APIRequest.
 
body = APIRequest.get("body");
Parameters
The parameter values passed in the request can be fetched using the component params of APIRequest.

If the parameter value is a key-value pair, then use:
parameters = APIRequest.get("params").get(<key>);

If the parameter value is a JSON object, name the key as arguments, and use:
parameters = APIRequest.get("params").get("arguments").get(<key>);

File Content
Any multipart content like a file can be fetched using the component file_content of APIRequest.
 
fileContent = APIRequest.get("file_content");
 
Maximum allowed file size is 4MB.
Supported file types: .txt, .csv, .xml, .json
User Information
Details about the user can be fetched using the component user_info of APIRequest.
 
userInfo = APIRequest.get("user_info");
Authentication Method
The name of the HTTP method (GET, POST, etc.) used in the request can be fetched using the component method of APIRequest.
 
method = APIRequest.get("method");
Authentication Type
The name of the authentication method used in the request can be fetched using the component auth_type of APIRequest.
 
authType = APIRequest.get("auth_type");
Headers
The information that is available in header (e.g. additional information about the request) can be fetched using the component headers of APIRequest.
 
headers = APIRequest.get("headers");
 
Return Type  
The return type of the function is String.

Create a Standalone Function

Following are the steps to create a standalone function that updates a custom field Restock Required of type Boolean in the Assets module to true:
  1. Navigate to Setup > Developer Space > Standalone Functions and click Create Function.



  2. In the Create Function overlay, do the following:
    1. Enter a Function Name
    2. In the Deluge Script Editor, write the below script for the standalone function.

      newRecordInfo = Map();
      newRecordInfo.put("Restock_Required__C",true);
      //Restock_Required__C is the API name of the custom field
      resp = zoho.fsm.updateRecord("Assets",APIRequest.get("params").get("id"),newRecordInfo);
      return resp;

  3. 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 the values to be passed to the map argument inputData. Click Execute.

    Sample argument:
    {"id":"2819XXXX0015"}



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


Once the function is created, toggle the status of the function to active and the REST API URL of the function will be displayed. Use this REST API URL to call this function. Click the copy [] icon to copy the URL.

Sample API URL: https://fsm.zoho.com/fsm/v1/functions/restockupdate/actions/execute?auth_type=oauth


Test in Postman

You can test the standalone function in Postman. To do so:
  1. Create a request to connect to the standalone function REST API. Use the following:
    a. Request method: POST
    b. Authorization: OAuth 2.0
    c. Callback URL: https://oauth.pstmn.io/v1/callback
    d. Auth URL: https://accounts.zoho.com/oauth/v2/auth
    e. Access Token URL: https://accounts.zoho.com/oauth/v2/token
    f. Scope: ZohoFSM.settings.functions.CREATE
    g. Generated Client IDClient Secret


When successfully executed, the value of the field Restock Required in the Assets module will be updated to true.


Types of Inputs

This section illustrates how different types of inputs can be passed to the standalone function.
  1. Execute the function using the GET method and pass arguments to the params component of APIRequest.



  2. Execute the function using the POST method and pass arguments to the params component of APIRequest.



  3. Execute the function using the POST method and pass value to the body component of APIRequest.



  4. Execute the function using the POST method and passing arguments to the file_content component of APIRequest.

    fileContent = APIRequest.get("file_content");
    myfile = fileContent.tofile("sf.csv");

    headers = APIRequest.get("headers");
    body = APIRequest.get("body");
    auth_type = APIRequest.get("auth_type");
    params = APIRequest.get("params");
    uinfo = APIRequest.get("user_info");
    method = APIRequest.get("method");

    info "File Content: " + fileContent;
    info "Headers: " + headers;
    info "Body: " + body;
    info "Auth Type: " + auth_type;
    info "Params: " + params;
    info "User Info: " + uinfo;
    info "Method: " + method;

    sendmail
    [
    from :zoho.adminuserid
    to :zoho.adminuserid
    subject :"Testing Standalone Function with File Attachment"
    message :APIRequest
    Attachments :file:myfile
    ]

    return APIRequest;

    The info messages will be available in the userMessage key and the return value of the function will be available in the output key.



Invoke Standalone Function within a Function

You can invoke a standalone function from another function in Zoho FSM, other Zoho applications, and any third-party application. Given below is a sample script for invoking a standalone function from another function.

rest = invokeurl
[
    url :"https://fsm.zoho.com/fsm/v1/functions/createcontact1/actions/execute?auth_type=oauth"
    type :GET
    parameters:{"Last_Name":"Robins","Email":"lucy.robins@zylker.com"}
    headers:Map()
    connection:"fsm"
];

return rest;

Manage Standalone Functions 

You can edit, delete, or clone a standalone function.

 



    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
                          Offline 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

                          Form Designer HR

                          Card Forms Food
                          Assign Forms Photography

                          Translate Forms Real Estate
                          Electronic Forms

                          Notification Emails for Forms Alternatives
                          Holiday Forms Google Forms alternative 
                          Form to PDF Jotform alternative





                                            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

                                                                                                              • 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 ...
                                                                                                              • 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 ...
                                                                                                              • Tips - Integrations

                                                                                                                Does the FSM-Invoice integration support bidirectional sync? Yes, the FSM-Invoice integration does support bidirectional sync. Is it possible to integrate FSM with an existing Invoice organization? Yes, it is possible to integrate FSM with an ...
                                                                                                              • Editions and Pricing

                                                                                                                The details of the various Zoho FSM editions and their pricing details are mentioned below. Features Edition Free Standard Professional Fixed Base Price Free 30.00 USD (billed monthly) 45.00 USD (billed monthly) 300.00 USD (billed annually) 420.00 ...
                                                                                                              • 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 ...
                                                                                                                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