Calling Functions within Functions - Standalone Functions

Calling Functions within Functions - Standalone Functions

Zoho CRM Standalone Functions

Standalone functions in Zoho CRM allow you to execute a function within another function. There are many practical use cases for standalone functions within Zoho CRM, including removing duplicate code and code reuse.

This discussion will cover how to use and implement Zoho CRM standalone functions. There are two main methods for using and implementing standalone functions:

  1. No Parameters
  2. With Parameters

No Parameters

We will first show how to execute a standalone function without any input parameters. This is the easiest way to execute these functions.

Setting Up Standalone Function

To setup a standalone function:

  1. Go to Setup -> Functions -> New Function
  2. Name the function and under Category select Standalone. Click Next.
  3. You'll be taken to the Deluge code editor.
  4. Edit your standalone function as below :

    1. /* STANDALONE FUNCTION */
    2. response = 'This is a test.';
    3. return response;
  5. Click Save & Execute.

Your custom function is ready to be called using the standalone namespace.

Setting Up Requesting Function

To setup a requesting function:

  1. Go to Setup -> Functions -> New Function
  2. Name the function and select any Category. Click Next.
  3. You'll be taken to the Deluge code editor.
    1. /* REQUESTING FUNCTION */
    2. standalone_function_values = standalone.my_standalone_function();
    3. info standalone_function_values;
  4. Click Save & Execute.

When you execute this requesting function, you should see the response from the standalone function printed console messages:

  1. /* CONSOLE */
  2. Info
  3. This is a test.
  4. Function executed successfully.

You can access futher JSON reponse messages from the page inspector, under Network -> Fetch/XHR -> Response. The page inspector needs to be opened prior to hitting "Save & Execute" to see these responses.

  1. /* EXAMPLE NETWORK RESPONSE FROM PAGE INSPECTOR */
  2. {
  3.     "result": {
  4.         "Tasks": [],
  5.         "message": {
  6.             "userMessage": [
  7.                 "This is a test."
  8.         ]
  9.         }
  10.     },
  11.     "unique_id": "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX",
  12.     "code": XXXX,
  13.     "function_id": "XXXXXXXXXXXXXXXXX",
  14.     "message": "Function Executed Successfully",*
  15.     "status": "Success"
  16. }

With Parameters

We will now show how to execute a standalone function with simple input parameters.

Setting Up Standalone Function

To setup a parameterised standalone function:

  1. Go to Setup -> Functions -> New Function
  2. Name the function and under Category select Standalone. Click Next.
  3. You'll be taken to the Deluge code editor.
    1. ---------------------------------
    2. PARAMETERS
    3. record_id: STRING
    4. ---------------------------------

    Edit your standalone function so that it is just:

    1. /* STANDALONE FUNCTION */
    2. response = zoho.crm.getRecordById("[Zoho Module]", record_id);
    3. return response;
  4. Click Save.

Your custom function can now be requested by another function using the standalone namespace.

Setting Up Requesting Function

To setup a requesting function:

  1. Go to Setup -> Functions -> New Function
  2. Name the function and select any Category. Click Next.
  3. You'll be taken to the Deluge code editor.
    1. /* REQUESTING FUNCTION */
    2. standalone_function_with_parameter_values = standalone.my_standalone_function_with_parameter(record_id);
    3. info standalone_function_with_parameter_values;

  4. Click Save & Execute.

When we execute the requesting function, enter the record_id from the relevant Zoho Module, you should see the following printed console messages:

  1. /* OUTPUT */
  2. Info
  3. {List, map or value should be returned to the console}
  4. Function executed successfully

    Access your files securely from anywhere

        Zoho Developer Community




                                  Zoho Desk Resources

                                  • Desk Community Learning Series


                                  • Digest


                                  • Functions


                                  • Meetups


                                  • Kbase


                                  • Resources


                                  • Glossary


                                  • Desk Marketplace


                                  • MVP Corner


                                  • Word of the Day



                                      Zoho Marketing Automation


                                              Manage your brands on social media



                                                    Zoho TeamInbox Resources

                                                      Zoho DataPrep Resources



                                                        Zoho CRM Plus Resources

                                                          Zoho Books Resources


                                                            Zoho Subscriptions Resources

                                                              Zoho Projects Resources


                                                                Zoho Sprints Resources


                                                                  Qntrl Resources


                                                                    Zoho Creator Resources



                                                                        Zoho Campaigns Resources


                                                                          Zoho CRM Resources

                                                                          • CRM Community Learning Series

                                                                            CRM Community Learning Series


                                                                          • Kaizen

                                                                            Kaizen

                                                                          • Functions

                                                                            Functions

                                                                          • Meetups

                                                                            Meetups

                                                                          • Kbase

                                                                            Kbase

                                                                          • Resources

                                                                            Resources

                                                                          • Digest

                                                                            Digest

                                                                          • CRM Marketplace

                                                                            CRM Marketplace

                                                                          • MVP Corner

                                                                            MVP Corner





                                                                              Design. Discuss. Deliver.

                                                                              Create visually engaging stories with Zoho Show.

                                                                              Get Started Now