Inline Functions
Standalone functions in Zoho CRM allow you to execute a function within another function. These inline functions remove duplicate code and facilitate code reuse.
There are two main methods for using and implementing standalone functions:
- Without Parameters
- With Parameters
1. Without Parameters
To create a standalone function
- Go to Setup > Developer Hub > Functions.
- In the Functions page, click + Create New Function.
- Choose the Category of the function. In our case, choose "Standalone".
- Click Create.
In the Create Function page, enter the following code.
/* STANDALONE FUNCTION */ response = 'This is a test.'; return response;
- Click Save. Your function is now ready to be called using the function namespace.
Setting Up Requesting Function
- Go to Setup > Developer Hub > Functions.
- In the Functions page, click + Create New Function.
- Choose a Category of the function.
- Click Create.
In the Create Function page, enter the following code.
/* REQUESTING FUNCTION */ standalone_function_values = standalone.standaloneTest(); info standalone_function_values;
- Click Save & Execute.
- You can see the response of the standalone function printed in the console.
2. With Parameters
To set up a function with parameters:
To create a standalone function
- Go to Setup > Developer Hub > Functions.
- In the Functions page, click + Create New Function.
- Choose the Category of the function. In our case, choose "Standalone".
- Click Create.
In the Create Function page, enter the following code.
/* STANDALONE FUNCTION */ response = zoho.crm.getRecordById("module_api_name",record_id); //Use the module's API name here return response;
- Click Edit Argument next to the function's namespace.
- enter "record_id" under Function Arguments, and choose the type as string.
- Click Save. Your function is now ready to be called using the function namespace.
Setting Up Requesting Function
- Go to Setup > Developer Hub > Functions.
- In the Functions page, click + Create New Function.
- Choose a Category of the function.
- Click Create.
In the Create Function page, enter the following code as shown.
/* REQUESTING FUNCTION */ standalone_function_with_parameter_values = standalone.funcWithParam(record_id); info standalone_function_with_parameter_values;
- Click Save & Execute.
- Enter the ID of any record from the module you specified in the standalone function.
- You can see the response of the standalone function printed in the console.