Restrictions and validations in subforms using Client Script

Restrictions and validations in subforms using Client Script



Hello everyone!

Welcome back to another exciting Kaizen post on Client Script! 

In this edition, we’re taking a closer look at Client Script Support for Subforms with the help of the following scenario.

" Zylker, a manufacturing company, uses the "Orders" module to place Orders . They fill in a subform called "Product List". Now, the Admin wants to enforce the following restrictions on this subform in detail page:
  • Disable row deletion
  • Prevent cloning and adding rows
  • Make the "Unit Price" field read-only for salespersons "

In this post,

  1. What are Subform event
  2. Possible actions in Subform using Client Script
  3. Use Case
  4. Disable row deletion within the subform
  5. Prevent cloning and addition of rows in subform
  6. Make the "Unit Price" field read-only for salespersons
  7. Summary
  8. Related Links


1.What are Subform Events

Subform events are triggered by user actions, such as adding or deleting rows or updating data in subform. These events allow you to run Client scripts for validation, automation, or dynamic updates. Here is the list of subform events.
  • onCellChange – Triggered when a cell value is changed and the keyboard or mouse focus moves out of the subform cell.
  • onRowAdd – Fires immediately after a new row is added in a subform.
  • onRowDelete – Executes right after a row is deleted from a subform.
  • beforeRowDelete – Invoked before a subform row is deleted; can be used to prevent deletion.
  • beforeRowUpdate – Triggered before a subform row is updated on Detail pages; useful for validations or preventing changes.
Click here to know more about Subform Events.
These events are supported in the following Pages of Zoho CRM
  • Standard - Create/Edit/Clone Pages, Detail page
  • Canvas - Create/Edit/Clone Pages, Detail page
  • Wizard - Create/Edit Pages
2. Possible actions in Subform using Client Script




Click here to view the detailed documentation about the Client Script ZDKs related to Subform.

Notes
 Note :

The setValue() method for a subform row and cell on the Detail Pages will only work when the row is in edit mode.

3. Solution

To accomplish the solution for the use case (stated at the beginning of the post), you need to create the following Client Scripts in detail Page.

3.A. Disable row deletion within the subform

  • Go to Setup > Developer Space > Client Script. Click +New Script.
  • Specify the details to create a script. 
  • Click Next.


Script :

  1. ZDK.Client.showAlert("Deleting rows is not allowed here");
  2. return false
  • This script blocks row deletion and shows an alert message.

  • Here is the syntax of showAlert().


  • You can see that the Client Script Triggers an alert message and prevents the deletion of rows.



3.B. Disable adding and cloning of rows in subform
  • Go to Setup > Developer Space > Client Script. Click +New Script.
  • Specify the details to create a script. 
  • Click Next.


Script: 

  1. ZDK.Client.showAlert("Adding and cloning rows is not allowed in this subform")
  2. return false;
  • You can see that the Client Script Triggers an alert message and prevents the addition of a new row. 



3.C. Make the "Unit Price" field read-only for salespersons

  • Go to Setup > Developer Space > Client Script. Click +New Script.
  • Specify the details to create a script. 
  • Click Next.

Script:
  1.   var user = ZDK.Apps.CRM.Users.fetchById($Crm.user.id);
  2. if (user.profile.name == 'Salesperson') {
  3.     var field_obj = ZDK.Page.getSubform("Product_list").getField('Unit_Price');
  4.     field_obj.setReadOnly(true);
  5. }

  • Here, 
  • $Crm refers to the Client Script Constant.





  • Click here to know more about other ZDKs and functions related to Client Script.
  • Here is how Client Script works.




Summary

1. What are the events available for subforms
2. What are the supported actions in subforms
3. How to make a field read only in a subform for a particular profile
4. How to prevent adding rows to a subform.

Related Links

Idea
Previous Post: Kaizen 185 - Subqueries in COQL AP |  Kaizen Collection: Home



      Zoho Campaigns Resources


        • Desk Community Learning Series


        • Digest


        • Functions


        • Meetups


        • Kbase


        • Resources


        • Glossary


        • Desk Marketplace


        • MVP Corner


        • Word of the Day


        • Ask the Experts


          Zoho CRM Plus Resources

            Zoho Books Resources


              Zoho Subscriptions Resources

                Zoho Projects Resources


                  Zoho Sprints Resources


                    Zoho Orchestly Resources


                      Zoho Creator Resources


                        Zoho WorkDrive Resources



                          Zoho CRM Resources

                          • CRM Community Learning Series

                            CRM Community Learning Series


                          • Tips

                            Tips

                          • Functions

                            Functions

                          • Meetups

                            Meetups

                          • Kbase

                            Kbase

                          • Resources

                            Resources

                          • Digest

                            Digest

                          • CRM Marketplace

                            CRM Marketplace

                          • MVP Corner

                            MVP Corner




                            Zoho Writer Writer

                            Get Started. Write Away!

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

                              Zoho CRM コンテンツ










                                ご検討中の方

                                  • Recent Topics

                                  • Audio/video quality issues with Zoho Meeting – Any roadmap for improvement?

                                    Hi Zoho Team, We’ve been using Zoho Meeting for both internal and external meetings, and unfortunately, the experience has been consistently poor. The video and audio quality are so unreliable that it often renders meetings ineffective—especially with
                                  • Getting daily summary report from SalesIQ

                                    Why am I suddenly getting a daily summary report from SalesIQ when I'm not even using it nor signed up to it knowingly?
                                  • Poor Search Results on Zoho CRM

                                    The search on Zoho CRM is quite poor. Salesforce has now published a new search, when will get this on Zoho? https://help.salesforce.com/s/articleView?id=data.c360_a_hybridsearch_index.htm&type=5
                                  • MULTI-SELECT LOOKUP - MAIL TEMPLATE

                                    Dear all how are you? We need to insert data from MULTI-SELECT LOOKUP in a email template, but I can't do that, when I'm creating the template I can't find the field to insert it. is there any solution? PVU
                                  • What’s New in Zoho Inventory | April 2025

                                    Hello users, April has been a big month in Zoho Inventory! We’ve rolled out powerful new features to help you streamline production, optimise stock management, and tailor your workflows. While several updates bring helpful enhancements, three major additions
                                  • 請求書に添付されているファイルをAPI経由で取得する際の問題について

                                    Books APIリファレンス 現在、Books APIを利用して請求書内の添付ファイルを取得するメソッドを構築しています。以下のコードを参考にしているのですが、添付ファイルが複数アップロードされている場合、responseにおいて2つ目のファイルの情報しか取得できない現象が発生しています。 headers_data = Map(); headers_data.put("Authorization", "Zoho-oauthtoken 1000.41d9xxxxxxxxxxxxxxxxxxxxxxxxc2d1.8fccxxxxxxxxxxxxxxxxxxxxxxxx125f");
                                  • Custom Function : Copy multilookup field to text field

                                    Hi, I'm a newbie on function programming, I try to copy text from a multi lookup field named "societe" to a text field named "societe2". I've used this code. In deluge script it seems to work, but when I trigger this function it doesn't work (Societe2
                                  • Save Draft in email bigin for desktop and mobile

                                    Hi any news to when we going to have the save draft for email in bigin desktop and mobile?
                                  • Zoho books and venmo

                                    Hi, Is there a way to hook Venmo into zoho books? I have a Venmo business account and want to be able to sync that. I know you can do it with the paypal integration but I dont want to use paypal for the fees and that doesnt allow me use/integrate my current
                                  • Clone a Module??

                                    I am giong to repurpose the Vendors module but would like to have a separate but very similar module for another group of contacts called Buyers. I have already repurposed Contacts to Sellers. Is it possible to clone (make a duplicate) module of Vendors
                                  • I can't found API for Sales Receipts

                                    Hello May you please help me to find an API document for Sales Receipts to get data and retrive a custom fields like Invoice and credit notes Regards
                                  • Introducing Keyboard Shortcuts for Zoho CRM

                                    Dear Customers, We're happy to introduce keyboard shortcuts for Zoho CRM features! Until now, you might have been navigating to modules manually using the mouse, and at times, it could be tedious, especially when you had to search for specific modules
                                  • Create custom field using API.

                                    Hi Zoho Support, can we create the custom field using Zoho API? Thanks, Parth Moderation Update: I'm locking this post as the feature has now been implemented. Please refer to the help link provided in the comment below.
                                  • Pipeline in Custom Modules

                                    I love the way the Sales Pipeline looks and functions with reports. I would like to add the save pipeline features and visualization to a custom module, however, I only see that these pipelines are only available for the Deals module. Is there a way to add pipelines to custom modules?
                                  • I don't really understand leads in the campaigns tab on Zoho CRM

                                    Good morning, fellow CRM users. I am having quite a hard time understanding the leads in the campaigns tab. In this particular campaign in the screenshot below, we sent out emails to our mailing leads through Zoho Campaigns, and the data is linked back
                                  • Attention API Users: Upcoming Support for Renaming System Fields

                                    Hello all! We are excited to announce an upcoming enhancement in Zoho CRM: support for renaming system-defined fields! Current Behavior Currently, system-defined fields returned by the GET - Fields Metadata API have display_label and field_label properties
                                  • Forecast performance analysis

                                    Last modified on 15/05/2023: Performance analysis in forecasts is now available for all Zoho CRM users in all DCs. Note that it was an early access feature available only upon request. As of May 10, 2023, it is rolled out for all Zoho CRM accounts. Find
                                  • Zoho Accounts and Book Keeping candidate required

                                    Urgently required data operator who can do following tasks: Purchase Bill Entry Sale Bill Entry Bank Entries Cash Book entries 40-75 entries per days
                                  • Assistance with Bulk Contact Import in Zoho Email Campaign

                                    I’m currently in the process of importing the Supermarkets customer list from Zoho Accounts into Zoho Email Campaigns. During the import, I’m being prompted to complete the "field mapping" section, but I’m unsure how to properly configure it to ensure
                                  • what is the header code and footer code, do you provide it for my website

                                    I am unable to understand few terms in making website, i need your help in header code, footer code, face book pixel integration etc..
                                  • Zoho DataPrep

                                    Zoho DataPrep is not updating the dataset. I post the updated dataset in Zoho WorkDrive under the same file name. (I delete the old file and upload the updated file with the same filename.) Zoho DataPrep is supposed to pull the dataset from Zoho WorkDrive,
                                  • Zoho Assist Unattended Access prevent my Windows 10 Pro business computers to sleep (ever)!

                                    Since I begin my trial period of Zoho Assist (Unattended Access) for business, I have sleep mode issues on all my business computer. In fact none of the sleep delay worked or even if I manually click the "Sleep" button into the Start Menu... After using the "powercfg -requests" command from Microsoft to troubleshoot sleep issues, I see that Zoho was responsible to all my sleep issues. Of course after uninstalling Zoho Assist Unattended Access from my test computer, the sleep mode returned to normal
                                  • Do my notebooks get transferred to a new phone?

                                    Hello I was wondering about a new phone and I'd like to know whether your notes are automatically transferred to the new device? Regards Will.
                                  • Introducing Zoho CRM for Everyone: A reimagined UI, next-gen Ask Zia, timeline view, and more

                                    Hello Everyone, Your customers may not directly observe your processes or tools, but they can perceive the gaps, missed hand-offs, and frustration that negatively impact their experience. While it is possible to achieve a great customer experience by
                                  • zoho notebook won't let me sign in on arch linux

                                    just gives me an eternal loop when i try to sign in within the app. signing in with google does the same, showing the blank white screen in browser at the same time
                                  • Where to find User Performance Page in CRM?

                                    Hi all Just googling answers to another forum post I've just put here when I found this page; https://help.zoho.com/portal/en/community/topic/forecast-performance-analysis-public-early-access-2023 It shows this User Performance Page screenshot. I can't
                                  • Does Zoho US Payroll now support employees in multiple states?

                                    Does Zoho US now support having employees in multiple US states? I looked at the site and can't find and of the restrictions on multiple states anywhere.
                                  • Zoho Payroll: Product Updates | April 2025

                                    At Zoho Payroll, we’re always working to make every payday feel effortless. And sometimes, that means listening closely to your unique needs. This month, we’ve focused on adding features that give you the flexibility to pay your employees based on your
                                  • Unveiling Cadences: Redefining CRM interactions with automated sequential follow-ups

                                    Last modified on 01/04/2024: Cadences is now available for all Zoho CRM users in all data centres (DCs). Note that it was previously an early access feature, available only upon request, and was also known as Cadences Studio. As of April 1, 2024, it's
                                  • Zoho Bigin | Adding users to a deal in bigin

                                    Hi, One of our ongoing POCs required adding users to a deal in Bigin. I found that we cannot add individuals using custom fields when we have an Express license. Is there any way to do it?
                                  • How to mass update member status in a CRM Campaign?

                                    Does anybody knows how to mass update member status of the contacts (or leads) associated to a campaign. I can click on a campaign record and go to the Contacts in the Related List fields but then it shows only 10 contacts per page at once. It is hard
                                  • Is there a way within Desk to allow for this timeline overlapping?

                                    We're encountering an issue where contract timelines for the same client at the same location might overlap or follow each other sequentially. Since a single client can have multiple contracts, and we offer various contract types, is there a way within
                                  • New in CRM: Dynamic filters for lookup fields

                                    Last modified on Oct 28, 2024: This feature was initially available only through Early Access upon request. It is now available to all users across all data centers, except for the IN DC. Users in the IN DC can temporarily request access using this form
                                  • Seriously - Create multiple contacts for leads, (With Company as lead) Zoho CRM

                                    In Zoho CRM, considering a comapny as a lead, you need us to allow addition of more than one contact. Currently the Lead Section is missing "Add contact" feature which is available in "Accounts". When you know that a particular lead can have multiple contacts, why was this feature not included. Now we have to miss out other contacts or enter them somewhere in the description.!!! this is bad.
                                  • Add an option to disable ZIA suggestions

                                    Currently, ZIA in Zoho Inventory automatically provides suggestions, such as sending order confirmation emails. However, there is no way to disable this feature. In our case, orders are automatically created by customers, and we’ve built a custom workflow
                                  • Translation support expanded for Modules, Subforms and Related Lists

                                    Hello Everyone!   The translation feature enables organizations to translate certain values in their CRM interface into different languages. Previously, the only values that could be translated were picklist values and field names. However, we have extended
                                  • Multiple team members to access one office PC

                                    Hello, We have a high-performance PC in our office that we use for resource-intensive tasks. All team members need to remotely access this PC from time to time. However, when I enable remote access for myself through Zoho Assist, the PC does not appear
                                  • CRM API w/ Self Client (Administrator): You do not have sufficient permission to associate this record. Contact your administrator.

                                    I am using the CRM API and am having an issue creating a contact. I've successfully created a contact linking to an existing account by ID, but then when I created a separate test account (which succeeded) and tried to create a contact linked to that
                                  • How to see history on Bulk send of Customer Statements

                                    Hi, We bulk send statements to customers every month via Books - every month we have customers emailing requesting a statement. Currently I have no visibility on if a customer was sent the statement or not and if our process is being followed or overlooked
                                  • How to avoid outgoing emails from Zoho CRM from being treated as SPAM/Junk when arriving in an Outlook Inbox?

                                    I just upgraded to Zoho CRM paid version so I could use the Mass EMail feature using a simple email template I prepared.   When testing this feature out, I sent emails to my Yahoo, GMail and to an Outlook EMail Inboxes.   Yahoo & GMail received the messages fine.    I have attached a print screen from my Outlook "Junk Folder" that shows the error message and note that at the bottom of the screen, it is obvioius that ZohoCRM's mail server is noted in the email's header/footer.  BELOW is the last few
                                  • Next Page