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 #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
    • Kaizen #152 - Client Script Support for the new Canvas Record Forms

      Hello everyone! Have you ever wanted to trigger actions on click of a canvas button, icon, or text mandatory forms in Create/Edit and Clone Pages? Have you ever wanted to control how elements behave on the new Canvas Record Forms? This can be achieved
    • Kaizen #142: How to Navigate to Another Page in Zoho CRM using Client Script

      Hello everyone! Welcome back to another exciting Kaizen post. In this post, let us see how you can you navigate to different Pages using Client Script. In this Kaizen post, Need to Navigate to different Pages Client Script ZDKs related to navigation A.
    • Recent Topics

    • Free Webinar : Unlock AI driven business insights with Zoho Inventory + Zoho Analytics

      Are you tired of switching between apps and exporting data to build customized reports? Say hello to smarter & streamlined insights! Join us for this exclusive webinar where we explore the power of the Zoho Inventory–Zoho Analytics integration. Learn
    • Critical Issue: Tickets Opened for Zoho Support via the Zoho Help Portal Were Not Processed

      Hi everyone, We want to bring to your attention a serious issue we’ve experienced with the Zoho support Help Portal. For more than a week, tickets submitted directly via the Help Portal were not being handled at all. At the same time no alert was posted
    • Hide/Show Subform Fields On User Input

      Hello, Are there any future updates in Hide/Show Subform Fields "On User Input"?
    • Cloning Item With Images Or The Option With Images

      Hello, when I clone an item, I expect the images to carry over to the cloned item, however this is not the case in Inventory. Please make it possible for the images to get cloned or at least can we get a pop up asking if we want to clone the images as
    • Archiving Contacts

      How do I archive a list of contacts, or individual contacts?
    • WorkDrive and CRM not in sync

      1/ There is a CRM file upload field with WorkDrive file set as the source: 2/ Then the file is renamed in WorkDrive (outside CRM): 3/ The File in CRM is not synced after the change in WorkDrive; the file name (reference) in CRM record is not updated (here
    • Custom validation in CRM schema

      Validation rules in CRM layouts work nicely, good docs by @Kiran Karthik P https://help.zoho.com/portal/en/kb/crm/customize-crm-account/validation-rules/articles/create-validation-rules I'd prefer validating data input 'closer to the schema'
    • Adding Default Module Image into mail merge field

      As with most people finding their way to these forums i have a specific requirement that doesn't seem to be supported by Zoho I have created 2 custom modules to suit my purpose 1 is an inventory type module that lists aluminium extrusions, and all relevant
    • Sync Data from MA to CRM

      Currently, it's a one-way sync of data from the CRM to MA. I believe we should have the ability to select fields to sync from MA to the CRM. The lead score is a perfect example of this. In an ideal world we would be able to impact the lead score of a
    • Is it possible to roll up all Contact emails to the Account view?

      Is there a way to track all emails associated with an Account in one single view? Currently, email history is visible when opening an individual Contact record. However, since multiple Contacts are often associated with a single Account, it would be beneficial
    • Update CRM record action

      Currently, MA only offers a "Push Data" action to push data to a CRM module. This action is built to cover the need to both create a new record and update an existing record. Because it has been implemented this way all required fields on the CRM module
    • Notes badge as a quick action in the list view

      Hello all, We are introducing the Notes badge in the list view of all modules as a quick action you can perform for each record, in addition to the existing Activity badge. With this enhancement, users will have quick visibility into the notes associated
    • What's new in Zoho One 2025

      Greetings! We hope you have all had a chance by now to get hands-on with the new features and updates released as part of ZO25. Yes, we understand that you may have questions and feedback. To ensure you gain a comprehensive understanding of these updates,
    • Good news! Calendar in Zoho CRM gets a face lift

      Dear Customers, We are delighted to unveil the revamped calendar UI in Zoho CRM. With a complete visual overhaul aligned with CRM for Everyone, the calendar now offers a more intuitive and flexible scheduling experience. What’s new? Distinguish activities
    • Add deluge function to shorten URLs

      Zoho Social contains a nice feature to shorten URLs using zurl.co. It would be really helpful to have similar functionality in a Deluge call please, either as an inbuilt function or a standard integration. My Creator app sends an email with a personalised
    • Edit default "We are here to help you" text in chat SalesIQ widget

      Does anyone know how this text can be edited? I can't find it anywhere in settings. Thanks!
    • Quick way to add a field in Chat Window

      I want to add Company Field in chat window to lessen the irrelevant users in sending chat and set them in mind that we are dealing with companies. I request that it will be as easy as possible like just ticking it then typing the label then connecting
    • How to create a two way Sync with CRM Contacts Module?

      Newbie creator here (but not to Zoho CRM). I want to create an app that operates on a sub-set of CRM Contacts - only those with a specific tag. I want the app records to mirror the tagged contacts in CRM. I would like it to update when the Creator app
    • Zoho Sheet for Desktop

      Does Zoho plans to develop a Desktop version of Sheet that installs on the computer like was done with Writer?
    • Allow Manual Popup Canvas Size Control

      Hello Zoho PageSense Team, We hope you're doing well. We would like to request an enhancement to the PageSense popup editor regarding popup sizing. Current Limitation: Currently, the size (width and height) of a popup is strictly controlled by the selected
    • Where is the settings option in zoho writer?

      hi, my zoho writer on windows has menu fonts too large. where do i find the settings to change this option? my screen resolution is correct and other apps/softwares in windows have no issues. regards
    • How to set page defaults in zoho writer?

      hi, everytime i open the zoho writer i have to change the default page settings to - A4 from letter, margins to narrow and header and footer to 0. I cannot set this as default as that option is grayed out! so I am unable to click it. I saved the document
    • Develop and publish a Zoho Recruit extension on the marketplace

      Hi, I'd like to develop a new extension for Zoho Recruit. I've started to use Zoho Developers creating a Zoho CRM extension. But when I try to create a new extension here https://sigma.zoho.com/workspace/testtesttestest/apps/new I d'ont see the option of Zoho Recruit (only CRM, Desk, Projects...). I do see extensions for Zoho Recruit in the marketplace. How would I go about to create one if the option is not available in sigma ? Cheers, Rémi.
    • How to import data from PDF into Zoho Sheet

      I am looking to import Consolidated Account Statement (https://www.camsonline.com/Investors/Statements/Consolidated-Account-Statement) into zoho sheet. Any help is appreciated. The pdf is received as attachment in the email, this document is password
    • Zoho Projects Android app: Integration with Microsoft Intune

      Hello everyone! We’re excited to announce that Zoho Projects now integrates with Microsoft Intune, enabling enhanced security and enterprise app management. We have now added support for Microsoft Intune Mobile Application Management (MAM) policies through
    • Cant't update custom field when custom field is external lookup in Zoho Books

      Hello I use that : po = zoho.books.updateRecord("purchaseorders",XXXX,purchaseorder_id,updateCustomFieldseMap,"el_books_connection"); c_f_Map2 = Map(); c_f_Map2.put("label","EL ORDER ID"); c_f_Map2.put("value",el_order_id); c_f_List.add(c_f_Map2); updateCustomFieldseMap
    • Wrapping up 2025 on a high note: CRM Release Highlights of the year

      Dear Customers, 2025 was an eventful year for us at Zoho CRM. We’ve had releases of all sizes and impact, and we are excited to look back, break it down, and rediscover them with you! Before we rewind—we’d like to take a minute and sincerely thank you
    • About Zoneminder (CCTV) and Zoho People

      Hi team I would like to implement a CCTV service for our branches, with the aim of passively detecting both the entry and exit of personnel enrolled in Zoho Peeple, but my question is: It is possible to integrate Zoho People with Zoneminder, I understand
    • Introducing the Zoho Projects Learning Space

      Every product has its learning curve, and sometimes having a guided path makes the learning experience smoother. With that goal, we introduce a dedicated learning space for Zoho Projects, a platform where you can explore lessons, learn at your own pace,
    • Create CRM Deal from Books Quote and Auto Update Deal Stage

      I want to set up an automation where, whenever a Quote is created in Zoho Books, a Deal is automatically created in Zoho CRM with the Quote amount, customer details, and some custom fields from Zoho Books. Additionally, when the Sales Order is converted
    • How to show branch instead of org name on invoice template?

      Not sure why invoices are showing the org name not the branch name? I can insert the branch name using the ${ORGANIZATION.BRANCHNAME} placeholder, but then it isn't bold text anymore. Any other ideas?
    • 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?
    • Unable to remove the “Automatically Assigned” territory from existing records

      Hello Zoho Community Team, We are currently using Territory Management in Zoho CRM and have encountered an issue with automatically assigned territories on Account records. Once any account is created the territory is assigned automatically, the Automatically
    • Kaizen #223 - File Manager in CRM Widget Using ZRC Methods

      Hello, CRM Wizards! Here is what we are improving this week with Kaizen. we will explore the new ZRC (Zoho Request Client) introduced in Widget SDK v1.5, and learn how to use it to build a Related List Widget that integrates with Zoho WorkDrive. It helps
    • Set connection link name from variable in invokeurl

      Hi, guys. How to set in parameter "connection" a variable, instead of a string. connectionLinkName = manager.get('connectionLinkName').toString(); response = invokeurl [ url :"https://www.googleapis.com/calendar/v3/freeBusy" type :POST parameters:requestParams.toString()
    • Possible to connect Zoho CRM's Sandbox with Zoho Creator's Sandbox?

      We are making some big changes on our CRM so we are testing it out in CRM's Sandbox. We also have a Zoho Creator app that we need to test. Is it possible to connect Zoho CRM's Sandbox to Zoho Creator's Sandbox so that I can perform those tests?
    • I Need Help Verifying Ownership of My Zoho Help Desk on Google Search Console

      I added my Zoho desk portal to Google Search Console, but since i do not have access to the html code of my theme, i could not verify ownership of my portal on Google search console. I want you to help me place the html code given to me from Google search
    • Timeline Tracker

      Hi Team, I am currently using Zoho Creator – Blueprint Workflows, and I would like to know if there is a way to track a timeline of the approval process within a Blueprint. Specifically, I am looking for details such as: Who submitted the record Who clicked
    • Primary / Other Billing Contacts

      If you add an additional contact to a Zoho Billing Customer record, and then mark this new contact as the primary contact, will both the new primary and old primary still receive notifications? Can you stop notifications from going to the additional contacts
    • Missing Import Options

      Hello, do I miss something or is there no space import option inside of this application? In ClickUp, you can import from every common application. We don't want to go through every page and export them one by one. That wastes time. We want to centralize
    • Next Page