Tip 32: How to set form field values using custom functions

Tip 32: How to set form field values using custom functions

Hi folks,

We're back today with our next tip—how to set form field values using custom functions. Before we get started, though, let's take a look at the basics.

What do you mean by setting values for a field in a form?

To assign a value to a form field based on a particular calculation or condition.

What are custom functions?

Custom functions are created by the user or developer to perform a particular action or process that's unique. It's often used when there is a need to repeat the same custom process many times without having to rewrite the code. For example, you can create a custom function to calculate the total price every time a user enters a discount code. Also note that a custom function can be reused anywhere within an application or across applications, saving you time and effort.

Common examples of using custom functions to:
  • Effectively manipulate data
  • Communicate with third-party applications
  • Integrate custom actions in Zoho Creator reports
Setting up a custom function includes the following steps: 
  1. Create a custom function.
  2. Test the custom function for accuracy.
  3. Associate the custom function with a workflow rule.
In this tip, you'll learn the basics of accessing the form fields inside of a custom function and how they can be used in Zoho Creator. Let's take a simple example of calculating the total score for marks obtained in 5 different subjects by each student in a class. This includes calculating their percentage and evaluating if they failed or passed the examination.

So, instead of repeating the same calculation for each student, we can create a custom function to perform the calculations based on form fields and call that function in form workflows. Let's look at it step by step.

Note: The objective here is to calculate the total marks [M1 + M2 + M3 + M4 + M5] obtained in 5 different subjects and the corresponding percentage.

Step 1: Create the form, with all the required fields

First, let's create a Student Marks form to capture the scores for a student in 5 different subjects, plus other basic details. Here, we've used the following fields:
  • Student Name (Name field)
  • Roll No (Single Line field)
  • Class (Single Line field)
  • Subject 1(Decimal field)
  • Subject 2 ( Decimal field)
  • Subject 3 (Decimal field)
  • Subject 4 (Decimal field)
  • Subject 5 (Decimal field)
  • Total Marks (Decimal field)
  • Percentage (Percentage field)
  • Result (Dropdown field)
Note: Please note that we have to provide initial values of 0.0 for all the fields involved in calculations, to avoid any runtime errors.



Step 2: Create the custom function to calculate the Total Marks, Percentage, and Result.

Now we have to create a custom function that will help us make all the calculations. 

In this case, we'll use the Map as the return type of the function, as we're collecting more than one value in the custom function. We can also use the List type for this function. So, before we define the calculation that needs to be done behind the scenes, the first thing that we need to do is define them all as arguments of the function with their respective data types. 
  1. Specify the function name as calulatemarks.
  2. Add a new namespace and name it Calculations.
  3. Select Map as the return type. 
  4. Specify arguments sub1, sub2, sub3, sub4, and sub5 as float types.
  5. Click Create Function.


Once a function is created, you can write the script as per your requirements using function arguments. These arguments hold the form field values when called in the form workflows.

  1. map calulatemarks(float sub1, float sub2, float sub3, float sub4, float sub5)
  2. {
  3.  tot = sub1 + sub2 + sub3 + sub4 + sub5;
  4.  perc = ((tot / 500) * 100);
  5.  if(sub1 > 35.00 && sub2 > 35.00 && sub3 > 35.00 && sub4 > 35.00 && sub5 > 35.00)
  6.  {
  7.   res = "Pass";
  8.  }
  9.  else
  10.  {
  11.   res = "Fail";
  12.  }
  13.  mp = Map();
  14.  mp.put("Total",tot);
  15.  mp.put("percerntage",perc);
  16.  mp.put("result",res);
  17.  return mp;
  18. }
Step 3: Trigger the custom function on the On User Input condition

Once the function is created, we need to call this function in the On User Input condition of all the fields used in the calculation to automate it. Also, we have to ensure that we choose the form fields correctly, with respect to the function arguments.



Step 4: Assign the values to the form fields

The custom function will return three values (Total Marks, Percentage, and Result). We have to assign those values into the form fields. Since we've used the Map return type, we can use the key declared in the function to get the calculated value and assign that variable to form fields.

  1. output = thisapp.Calculations.calulatemarks(input.Subject_1,input.Subject_2,input.Subject_3,input.Subject_4,input.Subject_5);
  2. input.Total = output.get("Total");
  3. input.Percentage=output.get("percentage");
  4. input.Result = output.get("result");

Here, we've illustrated it with simple calculation. However, based on your business use case, the calculations can be more complex, as well. The above discussed way of using form fields inside of custom functions will help you perform operations inside of custom functions as source objects, and use them wherever you need. 

We hope you liked this tip and decide to try it out. If you hit any roadblocks, feel free to reach out to us and we'll be happy to assist you.

    Access your files securely from anywhere


            All-in-one knowledge management and training platform for your employees and customers.






                                  Zoho Developer Community




                                                        • Desk Community Learning Series


                                                        • Digest


                                                        • Functions


                                                        • Meetups


                                                        • Kbase


                                                        • Resources


                                                        • Glossary


                                                        • Desk Marketplace


                                                        • MVP Corner


                                                        • Word of the Day


                                                        • Ask the Experts





                                                                  Manage your brands on social media



                                                                        Zoho TeamInbox Resources



                                                                            Zoho CRM Plus Resources

                                                                              Zoho Books Resources


                                                                                Zoho Subscriptions Resources

                                                                                  Zoho Projects Resources


                                                                                    Zoho Sprints Resources


                                                                                      Qntrl Resources


                                                                                        Zoho Creator 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


                                                                                                  Zoho Show Resources

                                                                                                    Zoho Writer

                                                                                                    Get Started. Write Away!

                                                                                                    Writer is a powerful online word processor, designed for collaborative work.

                                                                                                      Zoho CRM コンテンツ




                                                                                                        Nederlandse Hulpbronnen


                                                                                                            ご検討中の方





                                                                                                                      • Recent Topics

                                                                                                                      • Multi-currency and Products

                                                                                                                        One of the main reasons I have gone down the Zoho route is because I need multi-currency support. However, I find that products can only be priced in the home currency, We sell to the US and UK. However, we maintain different price lists for each. There
                                                                                                                      • Horrible download speed

                                                                                                                        Using a trial of Zoho Assist and downloading a 316 MB file on a 500/500 fibre connection to a remote computer on the same network took 7 mins to complete. On AnyDesk it took 1 min or so.
                                                                                                                      • Remove "Subject" as a required field on quotations

                                                                                                                        Not sure why, but Zoho has made 'Subject' a system defined required field. I'm not entirely sure why subject would be required as a key field (i.e. you cannot deactivate it or change it from required). It doesn't make much sense on many product quotations,
                                                                                                                      • Displaying only unread tickets in ticket view

                                                                                                                        Hello, I was wondering if someone might be able to help me with this one. We use filters to display our ticket list, typically using a saved filter which displays the tickets which are overdue or due today. What I'd really like is another filter that
                                                                                                                      • Best way to setup Inventory bin tracking for products with multiple boxes/crates

                                                                                                                        Hi - we need some advice from the community on setting up Items in the Inventory for products with multiple crates. We have large products in our warehouse where the product is delivered as two large (double pallet) crates. We've setup the Items for these
                                                                                                                      • Zoho Books | Product updates | August 2026

                                                                                                                        Hello users, July has been an exciting month for Zoho Books! This month, we're excited to introduce HTML PDF Templates, Placeholders as Pills, expanded approval workflows for Sales Returns and Journals, and significant compliance updates across the India,
                                                                                                                      • Tip #83- Give Customers a Faster Way to Reach You with the Quick Support Plugin – 'Insider Insights'

                                                                                                                        Hello Zoho Assist Community! Think about the last time a customer needed urgent support. They emailed in, waited for a response, got a session link, couldn't find it in their inbox, called back, and by the time the session actually started, a good chunk
                                                                                                                      • Frustrated with Zoho Assist QuickSUpport

                                                                                                                        Trialling Zoho Assist and I have a variety of clients. A lot are computer illiterate. Some have poor vision. The current support sessions are using apps which have desktop icons for the appropriate apps. I either connect on demand then the client approves
                                                                                                                      • Can't find field from ZCRM for a trigger

                                                                                                                        Hello, Currently I am revamping our CRM system and we have created second layouts from to try out new processes while not disrupting the old one. Moreover, we want to use different layouts for different processes. The issue is that when creating the ZCRM
                                                                                                                      • Discount Per Item / Option Removed

                                                                                                                        Hi, I was using Zoho Books for three years now and very saticfied. Now, as we try to add an invoice, we founds that the discount option per item was takn away, and a discount from total was implemented. However, we have cases when we add a diffrent discount to each item. Was this option removed permanently? Thanks, 
                                                                                                                      • Any Possible to change the challan type in Delivery challan ?

                                                                                                                        Hello Team, We need to add the more values in challan type in delivery challan module in Zoho Books.So how to add additional values in challan type field. Please find following snap for your reference. Thanks in Advance, Thisai Moorthy.
                                                                                                                      • Zoho ERP | Product updates | July 2026

                                                                                                                        Hello users, We're back with another round of updates to help you streamline your operations. This month's release brings new features and enhancements designed to help you work more efficiently. Read on to discover everything that's new in Zoho ERP this
                                                                                                                      • Show when an invoice has been viewed

                                                                                                                        It would be nice to know if/when a customer has viewed an invoice. This would mean not having PDF attachments and just have the link to the invoice. My previous invoicing solution had this feature and I did not realize how much I used it until it was gone. Would this be possible, or this already available and I am just missing it?
                                                                                                                      • Customer image field

                                                                                                                        I created a custom image field for estimates, and it works as expected. The only issue I have is that I want to be able to place the custom image field in the estimate invoice. Is there a way I can do that, the field does not give the option to display
                                                                                                                      • Zoho Books | Product updates | March 2026

                                                                                                                        Hello users, We’ve rolled out new features and enhancements in Zoho Books. From Advanced Reporting Tags to the ability to mark projects as completed, explore the latest updates designed to improve your bookkeeping experience. Introducing Advanced Reporting
                                                                                                                      • Separator line

                                                                                                                        Is there a way i can insert a line in an invoice or quote without showing qty or prices? e.g. Options I Item description qty and price Option II Item description qty and price Thanks
                                                                                                                      • All new Address Field in Zoho CRM: maintain structured and accurate address inputs

                                                                                                                        Availability Update: 29 September 2025: It's currently available for all new sign-ups and for existing Zoho CRM orgs which are in the Professional edition exclusively for IN DC users. 2 March 2026: Available to users in all DCs except US and EU DC. 24
                                                                                                                      • BCC Drop Box Centralisation

                                                                                                                        Hi Team, For the last few years, I have had a question related to the Zoho CRM BCC Dropbox feature. Although BCC Dropbox is very useful for tracking customer email communication, I have always wondered why its configuration is managed at the individual
                                                                                                                      • Kiosk Page Refresh

                                                                                                                        We have a Kiosk running from a button in contacts to update values and also add related lists, which works great, but when the kiosk is finished the page does not refresh to show the changes. Is there a way to force the contact to refresh/update when
                                                                                                                      • CRM Integration - Option to Sync Reporting Tags

                                                                                                                        It would be nice to be able to sync reporting tags in Zoho Finance to a custom field in Zoho CRM. My use case is for a Customer in Finance to an Account in CRM (and vice-versa, of course), but I'm sure it's pretty obvious that this could also be used
                                                                                                                      • Join the Zoho Desk Virtual Classroom Training (VCRT)

                                                                                                                        Hello everyone, Have you heard about Zoho's Virtual Classroom Training (VCRT)? Zoho Desk's Virtual Classroom Training offers end-to-end training for Zoho Desk users. Join the VCRT and get hands-on guidance for setting up Zoho Desk and getting your business
                                                                                                                      • Make Rich Text fields available in Canva Print Views

                                                                                                                        Everything is on the title. I don't really understand why this is not already possible as Rich Text Fields are available in Canva Detailed Views for example.
                                                                                                                      • Zoho CRM Approval Process based on Field Update

                                                                                                                        Hello, In current structure, Zoho CRM send records to approval based on record creation and edit.  I think, it should be to set approval process trigger based on any field update in record. When the user update any field, the record can assign to approval
                                                                                                                      • Where do I edit the "Welcome to [portal name]" message

                                                                                                                        I am looking for a way to edit the "Welcome to" part of the message that is seen on the landing page (ex: https://help.zoho.com/portal/en/home). When I use the French interface, it doesn't make sense... I want to change it from "Bienvenue chez" to" Bienvenue au". Thanks!
                                                                                                                      • Approve records efficiently: Useful enhancements to My Jobs module and Approval process in Zoho CRM

                                                                                                                        Dear Customers, As you might know, approval process is a process automation tool that allows you to automate approvals in your organization and My Jobs is where you approve requests from a single point of view. Here's how you'd go about it: You’d add
                                                                                                                      • Filter isn't

                                                                                                                        The ability to filter the history of a given flow to a specific status however it would be great to have the ability to filter to a status that isn't something for example if i want to find all history that isn't complete.
                                                                                                                      • Introducing the Store Locator widget

                                                                                                                        Hello everyone! Your website is often the first place customers visit before deciding where to shop. But when they can't quickly find the nearest store, check business hours, or get directions, many leave your website and search elsewhere. Every extra
                                                                                                                      • Important updates to your connectors

                                                                                                                        Hello everyone, Greeting from Zoho Creator! We're excited to announce that we'll be rolling out significant backend updates to Zoho Creator's built-in connectors to enhance security by following the latest frameworks. The existing version of some of the
                                                                                                                      • Important updates to your Salesforce integrations in Zoho Creator

                                                                                                                        Hello everyone, We're writing to inform you of an important change regarding Salesforce integrations in Zoho Creator. Salesforce has introduced new security requirements for third-party platforms that connect with their services via APIs. To comply with
                                                                                                                      • Password Policy in Zoho Mail: Set password rules to keep your organization secure

                                                                                                                        Weak or repetitive passwords are one of the most common causes of unauthorized account access in organizations. Zoho Mail's Password Policy feature allows administrators to define and enforce specific password requirements for all users in the organization,
                                                                                                                      • What is Workqueue and how to hide it?

                                                                                                                        Hi, My CRM suddenly have this "Workqueue", may I ask how to set the permission of this tab?
                                                                                                                      • Zoho Community Digest - July 2026| Part 4

                                                                                                                        Hi everyone, and welcome back! We're closing out July with a strong final week, from a major LinkedIn integration in Zoho Recruit to AI-powered forecasting in Zoho Analytics. There are also a few heads-ups worth noting, including API changes in Zoho CRM
                                                                                                                      • Zoho CRM Community Digest - July 2026| Part 2

                                                                                                                        Hello everyone! The second half of July brought five CRM updates, including a heads-up for developers on API changes coming in October, one Quick Win on keeping your attribution data intact through lead conversion, two Dev's Corner threads worth bookmarking,
                                                                                                                      • Shared Snippets Everyone

                                                                                                                        Hi, Now that the Shared Snippets have been released and I think will be the most used feature implemented in 2023 :) Creating and Using Snippets in Ticket Responses - Online Help | Zoho Desk Maintain consistency in ticket responses with shared snippets
                                                                                                                      • Keeping project teams in the know with Zoho Cliq

                                                                                                                        Project management is all about processes, data flow, and maintaining order. But communicating appropriate information at crucial times to stakeholders is as important as the moving parts of a project. Zoho Cliq can facilitate effective communication
                                                                                                                      • Enable Credit Note creation for Sales Returns BEFORE receiving goods

                                                                                                                        Currently, it is not possible to issue a Credit Note linked to a Sales Return until the goods have been officially marked as "received" in the system. In our business, we often need to issue a credit note to our clients immediately upon the initiation
                                                                                                                      • Getting Internal Server Error message when filing for MTD

                                                                                                                        I am trying to file for the MTD submission, and after I filled in all the information and click (Fetch Obligation) this message "Internal Server Error [500]" pops up. I have been trying for awhile and its still the same. What shall I do as today is deadline
                                                                                                                      • No access to change view permission for team members

                                                                                                                        Hi, I want team members to be able to update the percentage progress on their goals at mid year. Currently they cannot edit this, they can only update the comments against the goals. The ability to add view permission to goal progress for team members
                                                                                                                      • Turn your Zoho One Home into your workspace with Dashboard 2.0

                                                                                                                        When you open Zoho One, you probably don't need to see everything. You need to see what matters to you. A sales manager may want to track pipeline and revenue. An HR manager may want to monitor employee information. A business leader may want a quick
                                                                                                                      • Zoho Assist Feature Update: August 2026

                                                                                                                        Web Forms Web Forms in Zoho Assist help you collect support requests directly from your website and route them to the right team. Embed a customizable form so customers can raise issue details or join an active remote session using a session ID. Depending
                                                                                                                      • Next Page