My go to On Load Client Script - Fast, efficient, and works for ALL profiles; Hides everything except initial fields

My go to On Load Client Script - Fast, efficient, and works for ALL profiles; Hides everything except initial fields

This is my on Load client script that I use for Create pages. I use a modified version for Edit and Display pages which you can create yourself using the same basic structure that I will give you below. First up, the script. Below that will be an explanation of how it works.

  1. const subformAPINames = ['Deal_Quotes', 'Assets']; // Declare all your visible subform API names
  2. const formAPINames = Object.keys(ZDK.Page.getForm().getValues()); // Get all API names visible on the page
  3. const fieldAPINames = formAPINames.filter(x => !subformAPINames.includes(x)); // Remove the Subform API names from the array above, creating an array of field API names.
  4. const visibleFields = [
  5.     "Account_Name", "Closing_Date", "Contact_Name", "Current_Task", "Customer_Reference",
  6.     "Deal_Name", "Description",
  7.     "Expected_Conversion", "Info_Required",
  8.     "Next_Project_Follow_Up", "Opened_Date",
  9.     "Product_Range", "Source", "Stage", "Type_2",'CCL','Asset'
  10. ];
  11. const readOnlyFields = ['Last_Follow_Up','Next_Project_Follow_Up','Opened_Date','Deal_Name','Current_Task','Stage']; // Declare all fields required to be read only on page load
  12. const mandatoryFields = ['Account_Name','Type_2','Product_Range','Description']; // Declare all fields required to be mandatory
  13. fieldAPINames.forEach(f => { if (!visibleFields.includes(f)) { ZDK.Page.getField(f).setVisibility(false); } }); // Hides all fields except subforms
  14. readOnlyFields.forEach(f => { if (fieldAPINames.includes(f)) { ZDK.Page.getField(f).setReadOnly(true) } }); // Sets all read only fields as such
  15. mandatoryFields.forEach(f => { if (fieldAPINames.includes(f)) { ZDK.Page.getField(f).setMandatory(true) } }); // Sets all read onlymandatory fields as such
  16. subformAPINames.forEach(s => (Object.keys(ZDK.Page.getSubform(s).getRow(0).getValues()).forEach(f => ZDK.Page.getSubform(s).getField(f).setVisibility(false)))); // Hides all subform fields
So, how does this work?

This script works with all profiles with all field permissions. You don't need to worry about creating separate scripts or separate blocks for different profiles.
  1. First we declare all the subform API names in the module
  2. Next, we grab all the API names visible to the logged in user on page Load.
    1. This doesn't distinguish the type of field, which is why we need to declare the subform API names manually
  3. Now we remove the subform field API names from step 2. This gives us 2 lists, or arrays. 1 array with just field API Names, and 1 array with just subform API Names.
  4. Next, we're going to have 3 arrays. Visible Fields, Mandatory Fields, Read Only Fields. Within these arrays, we're going to list ALL the fields that we want in each category
    1. Again, it doesn't matter if the logged in user has access to the field or not.
  5. Now, the loops begin:
    1. For each field in the fieldAPINames array, if the field name is NOT in the list of visible fields, hide it.
    2. For each field in Mandatory fields, if the field name IS found in the fieldAPINames array, make it mandatory
    3. For each field in the Read Only Array, if the field name IS found in the fieldAPINames array, make it read only
  6. Before we go on to the subforms, the above loops only work on the list of fields available to the user. If we were to make a field "Profit" read only, but it's not available to the particular user, "Profit" won't be in fieldAPINames, therefore the script won't try to make it read only... the script doesn't know "Profit" exists.
    1. If we were to use ZDK.Page.getField("Profit").setvisibility(false) and the user does not have access to the field, the script would fail. This script is completely immune to such a situation.
  7. Next, the subforms. We don't actually get the subform field names when we get all field API names. We get the subform API name, but not the individual subform field API Names. However, each subform is always populated with 1 row, even if that row is completely empty, it doesn't matter.
    1. The last line cycles through each subform. If the subform was found on the page, it executes the next nested loop.
    2. For each visible subform, we get the first row and strip out all the field API names.
    3. Now we have the subform field API names, we hide all the ones we don't want visible. In my case, I don't want any subform fields visible yet, so I just hide all of them

And that's it. One final note. I specify the visible fields rather than the hidden fields since there's usually less visible fields, so it makes sense to focus on the shorter list of fields that should be visible rather than the list of fields that should be hidden. It also means that any new fields are automatically hidden without having to alter the script.

In my next post, I will share my script structure of an On Page Change event.
    • Sticky Posts

    • Kaizen #198: Using Client Script for Custom Validation in Blueprint

      Nearing 200th Kaizen Post – 1 More to the Big Two-Oh-Oh! Do you have any questions, suggestions, or topics you would like us to cover in future posts? Your insights and suggestions help us shape future content and make this series better for everyone.
    • Kaizen #226: Using ZRC in Client Script

      Hello everyone! Welcome to another week of Kaizen. In today's post, lets see what is ZRC (Zoho Request Client) and how we can use ZRC methods in Client Script to get inputs from a Salesperson and update the Lead status with a single button click. In this
    • Kaizen #222 - Client Script Support for Notes Related List

      Hello everyone! Welcome to another week of Kaizen. The final Kaizen post of the year 2025 is here! With the new Client Script support for the Notes Related List, you can validate, enrich, and manage notes across modules. In this post, we’ll explore how
    • Kaizen #217 - Actions APIs : Tasks

      Welcome to another week of Kaizen! In last week's post we discussed Email Notifications APIs which act as the link between your Workflow automations and you. We have discussed how Zylker Cloud Services uses Email Notifications API in their custom dashboard.
    • Kaizen #216 - Actions APIs : Email Notifications

      Welcome to another week of Kaizen! For the last three weeks, we have been discussing Zylker's workflows. We successfully updated a dormant workflow, built a new one from the ground up and more. But our work is not finished—these automated processes are
    • Recent Topics

    • Super Admin Logging in as another User

      How can a Super Admin login as another user. For example, I have a sales rep that is having issues with their Accounts and I want to view their Zoho Account with out having to do a GTM and sharing screens. Moderation Update (8th Aug 2025): We are working
    • Blocklist candidates in Zoho Recruit

      We’re introducing Block Candidate, which helps recruiters to permanently restrict a candidate from applying to current/future job openings. Once the candidate is blocked, they will no longer be able to participate in the recruitment process. This will
    • Layout Rules Don't Apply To Blueprints

      Hi Zoho the conditional layout rules for fields and making fields required don't work well with with Blueprints if those same fields are called DURING a Blueprint. Example. I have field A that is used in layout rule. If value of field A is "1" it is supposed to show and make required field B. If the value to field A is "2" it is supposed to show and make required field C. Now I have a Blueprint that says when last stage moves to "Closed," during the transition, the agent must fill out field A. Now
    • From Zoho CRM to Paper : Design & Print Data Directly using Canvas Print View

      Hello Everyone, We are excited to announce a new addition to your Canvas in Zoho CRM - Print View. Canvas print view helps you transform your custom CRM layouts into print-ready documents, so you can bring your digital data to the physical world with
    • Admin asked me for Backend Details when I wanted to verify my ZeptoMail Account

      Please provide the backend details where you will be adding the SMTP/API information of ZeptoMail Who knows what this means?
    • Zoho Desk - Upsert Ticket

      Hi Desk Team, It is common to request more information from end-users. Using forms is a great way to ensure all the required information is collected. It would be great if there were an "upsert" option on the Zoho Form -> Zoho Desk integration which would
    • All new Address Field in Zoho CRM: maintain structured and accurate address inputs

      The address field will be available exclusively for IN DC users. We'll keep you updated on the DC-specific rollout soon. It's currently available for all new sign-ups and for existing Zoho CRM orgs which are in the Professional edition. Latest update
    • Client Side Scripts for Meetings Module

      Will zoho please add client side scripting support to the meetings module? Our workflow requires most meeting details have a specific format to work with other software we have. So we rely on a custom function to auto fill certain things. We currently
    • Introducing Multiple Sandbox Types and Support for Module's Data Population

      Register here for the upcoming Focus Group webinar on Multiple Sandbox | Help documentation to learn more about the new enhancements Hello everyone,  Sandbox in CRM is a testing environment for users to create and test new configurations like workflow
    • Zoho CRM for Everyone's NextGen UI Gets an Upgrade

      Hello Everyone We've made improvements to Zoho CRM for Everyone's Nextgen UI. These changes are the result of valuable feedback from you where we’ve focused on improving usability, providing wider screen space, and making navigation smoother so everything
    • CRM x WorkDrive: File storage for new CRM signups is now powered by WorkDrive

      Availability Editions: All DCs: All Release plan: Released for new signups in all DCs. It will be enabled for existing users in a phased manner in the upcoming months. Help documentation: Documents in Zoho CRM Manage folders in Documents tab Manage files
    • Creator Offline

      We had online access setup and working on our iphones. We have just set it up on an 'Android Tablet' and it is not downloading all the images? We use it to show customers our catalogue. Any ideas. Offline components all setup on both devices
    • Drag 'n' Drop Fields to a Sub-Form and "Move Field To" Option

      Hi, I would like to be able to move fields from the Main Page to a Sub-Form or from a Sub-Form to either the Main Page or another Sub-Form. Today if you change the design you have to delete and recreate every field, not just move them. Would be nice to
    • Enable or disable any Field Rule!

      Hello Zoho Forms Community, We are excited to announce a powerful new enhancement to Field Rules that gives you greater control and flexibility in managing your form logic! Previously, if you wanted to temporarily deactivate a field rule, you had two
    • Marketing Tip #20: Increase traffic with strong meta titles and descriptions

      Meta titles and descriptions are what people see first on search results before they ever click through to your website. If your pages use generic titles or basic descriptions, you miss the chance to stand out, and search engines may not know which page
    • Different form submission results for submitter and internal users

      I'm looking for suggestions on how to show an external submitter a few results while sending internal users all the results from the answers provided by the external user. The final page of our form has a section with detailed results and a section with
    • Kanban view on Zoho CRM mobile app!

      What is Kanban? The name doesn't sound English, right? Yes, Kanban is a Japanese word which means 'Card you can see'. As per the meaning, Kanban in CRM is a type of list view in which the records will be displayed in cards and categorized under the given
    • Not able to delete a QC nor able to revert or create a cycle of manufacturing for QC failed Jobs

      Not able to delete a QC nor able to revert or create a cycle of manufacturing for QC failed Jobs
    • Dheeraj Sudan and Meenu Hinduja-How do I customize Zoho apps to suit my needs?

      Hi Everyone, I'm Meenu Hinduja and my husband Dheeraj Sudan, run a business. I’m looking to tweak a few things to fit my needs, and I’d love to hear what customizations others have done. Any tips or examples would be super helpful! Regards Dheeraj Sudan
    • Zoho Desk blank screen

      opened a ticket from my email, zoho desk comes up blank, nothing loads. our receptionist also gets the same thing under her login on her computer. our sales rep also gets same thing on zoho desk at his home on a different computer. I tried clearing cache/history/cookies,
    • is there any way to change the "chat with us now" to custom message?

      is there any way to change the "chat with us now" to custom message? I want to change this text
    • Deprecation Notice: OpenAI Assistants API will be shut down on August 26, 2026

      I recieved this email from openAI what does it means for us that are using the integration and what should we do? Earlier this year, we shared our plan to deprecate the Assistants API once the Responses API reached feature parity. With the launch of Conversations,
    • Capture Last check-in date & days since

      I have two custom fields on my Account form, these are "Date of Last Check-In" and "Days Since Last Contact" Using a custom function how can I pull the date from the last check-in and display it in the field "Date of Last Check-In"? and then also display the number of days since last check-in in the "Days SInce Last Contact" field? I tried following a couple of examples but got myself into a bit of a muddle!
    • Any recommendations for Australian Telephony Integration providers?

      HI,  I am looking for some advice on phone providers as we are looking to upgrade our phone system, does anybody have experience with any of the Australian providers that integrate with CRM Telephony? So far we are looking at RingCentral and Amazon Connect, and would love to hear feedback on any of the other providers you might have tried.  Thank you
    • Why is the ability Customize Calls module so limited?

      Why can't I add additional sections? why can't I add other field types than the very limited subset that zoho allows? Why can I only add fields to the outbound/inbound call sections and not to the Call Information section?
    • CRM gets location smart with the all new Map View: visualize records, locate records within any radius, and more

      Hello all, We've introduced a new way to work with location data in Zoho CRM: the Map View. Instead of scrolling through endless lists, your records now appear as pins on a map. Built on top of the all-new address field and powered by Mappls (MapMyIndia),
    • Enhance Appointment Buffers in Zoho Bookings

      There was previously a long-standing feature request related to enhancing the way appointment buffers work in Zoho Bookings, but it looks like the original post has been deleted. I am therefore adding a new request that Zoho Bookings adjust how appointment
    • Subscriptions for service call

      So we install products and we want to offer a service contract for the customers yearly service calls to be billed monthly. So ideally at some point we want to email them a quote for their needs. WE will choice it our end based on the equipment. It would
    • Add RTL and Hebrew Support for Candidate Portal (and Other Zoho Recruit Portals)

      Dear Zoho Recruit Team, I hope you're doing well. We would like to request the ability to set the Candidate Portal to be Right-to-Left (RTL) and in Hebrew, similar to the existing functionality for the Career Site. Currently, when we set the Career Site
    • Zoho recruit's blueprint configuration is not functioning as mapped

      Current Status: Zoho Blueprint is not functioning as configured. Issue: We are moving a Candidate status in Zoho Recruit "for active file" but we encountered: "Status cannot be changed for records involved in Blueprint." This happens to various client
    • Delay in rendering Zoho Recruit - Careers in the ZappyWorks

      I click on the Careers link (https://zappyworks.zohorecruit.com/jobs/Careers) on the ZappyWorks website expecting to see the job openings. The site redirects me to Zoho Recruit, but after the redirect, the page just stays blank for several seconds. I'm
    • How to add interviews through API

      I'm trying to add an interview without much luck. The documentation gives examples of adding just about everything except an interview. However, the issue might be the way I'm formatting it, because the documentation is unclear to me. It seems as if the xml should be passed in the url, which seems unusual. I've tried the data as both plain and character escaped, but nothing seems to work, nor do I even get an error response. https://recruit.zoho.com/recruit/private/xml/Interviews/addRecords?authtoken=***&scope=recruitapi&version=2&xmlData=<Interviews> <row
    • Connection to other user

      Zoho Cliq handles sharing of Custom OAuth Connections that require individual user logins.
    • How to invite friends on other social media platforms to one of my group chats in arattai?

      Hello, I have formed chat groups in arattai. I want to invite my friends on other social media platforms like WhatsApp/ FB to one of my groups. Different friends would be invited to different groups. How to share an invite link of one of my groups to
    • Cliq does not sync messages after Sleep on Mac

      I'm using the mac app of Cliq. When I open my mac after it was in sleep mode, Cliq does not sync the messages that I received. I always have to reload using cmd + R, which is not what I want when using a chat application.
    • Optimum CRM setup for new B2B business

      Can some advise the most common way to setup Zoho CRM to handle sales for a B2B company? Specifically in how to handle inbound/outbound emails. I have spent hours researching online and can't seem to find an accepted approach, or even a tutorial. I have
    • Facing Issues with Sites Mobile font sizes

      my page renediaz.com is facing issues mobile view, when i try to lower font sizes in home page, instead of changing the size, it changes the line space
    • Does the Customer “Company Name” field appear anywhere in the Zoho Books UI outside of PDFs?

      Hi everyone, I’m trying to understand how the Company Name field is actually used in Zoho Books. There is a Company Name field on the customer record, but when viewing transactions like a Sales Order in the normal UI (non-PDF view), that field doesn’t
    • Set expiration date on document and send reminder

      We have many company documents( for example business registration), work VISA documents. It will be nice if we can set a expiry date and set reminders ( for example 90 days, 60 days, 30 days etc.,) Does Zoho workdrive provide that option?
    • Analytics : How to share to an external client ?

      We have a use case where a client wants a portal so that several of his users can view dashboards that we have created for them in Zoho Analytics. They are not part of our company or Zoho One account. The clients want the ability to have user specific,
    • Next Page