Customize Buttons using Client Script

Customize Buttons using Client Script

Hello everyone! 

Welcome back to another interesting Kaizen post. In this post, we can discuss how to customize buttons using Client Script. 


In this kaizen post,
  1. Need for customizing buttons 
  2. ZDKs related to Buttons
  3. Use Case to customize button using Client Script
  4. Solution
  5. Summary
  6. Related Links

1. Need for customizing buttons

  • Enforcing Workflow Steps - By disabling certain buttons based on conditions, you can guide users through a predefined workflow. For example, if you want to notify the customer, when the order is in a particular stage, you can disable the button for other stages.
  • Customize buttons based on your business - You can modify button labels using Client Script to match your company's specific terms.If a button is part of a step-by-step process, change the label to match each step, making it more intuitive for users. 

2. ZDKs related to Buttons

Client Script empowers you to customize buttons and here is the list of ZDKs and Client Script functions to customize standard and custom buttons. 

  • getButtonByID(id)  - You can get the Pages' Button by ID.
  • getButton(api_name)  - You can get the Pages' Button by api name.
  • getButtons()  - You can get the list of buttons in the Page as an array.
  • getId() Using this, you can get the id of button.
  • getType()Using this, you can get the type of button.
  • getLabel()Using this, you can get the name of the button.
  • getApiName()  - Using this, you can get the API name of the button.

3. Use Case for customizing buttons:

      Zylker is a manufacturing company. The Sales representatives initiate the process by creating new deals in the CRM for potential customers or business opportunities.  So they are given the "create" permission. But in real time, there are high chances for an approved record to get cloned, which cannot be permitted. So, Zylker wants to disable the "Clone" button for users having a "Sales" profile.
As per their workflow, once the deal's stage is "Closed Won" a mail should be sent to the Manager and the customer. For this they have a custom button named "mail". But this mail button should not be sent when the deal is in other stages. To ensure this, Zylker wants to disable this button for all other stages of the deal.
Also, for better clarity, Zylker wants to rename the "save" button as "Create Deal" in the Create Page (Standard).

4. Solution:

As per the requirement, you need to create three Client Scripts. 
A. Disable "Clone" button Detail Page (Standard) when the page loads
B. Disable "Mail" button Detail Page (Standard) when the stage changes
C. Rename button in Create Page (Standard)

A. Disable Clone and mail buttons in  Detail Page (Standard)
  • Create a Client Script for  Detail Page (Standard) with onLoad Page event
  • For details about how to create a Client Script, click here.
  • Enter the following script and save.

 // Disable the standard "clone" button
var user = ZDK.Apps.CRM.Users.fetchById($Crm.user.id);
 if (user.profile.name !== 'Sales') {
var clone_btn = ZDK.Page.getButton('clone');
clone_btn.disable();
}

  • In the above script, "clone" is the api name of the standard button.
  • Here is the screenshot that shows the disabled "Clone" button for a user only with Sales Profile.

  • Here is the screenshot that shows the "Clone" button for a user with a non-sales profile user. That is, "Clone" button is not disabled for users having profiles other than "Sales" profile.


B. Disable "Mail" button Detail Page (Standard) when the stage changes
  • Create a Client Script for  Detail Page (Standard) with onChange field event for the field Stage.
  • For details about how to create a Client Script, click here.
  • Enter the following script and save.

// Disable the custom "mail" button
var stage_field = ZDK.Page.getField("Stage");
if (stage_field.getValue != 'Closed Won') {
   ZDK.Page.getButtons().find(a => a.getLabel() === 'mail').disable();
}
  • Here is the screenshot that shows the disabled "mail" button for a deal with the "Closed Won" stage.

  • Here is the screenshot that shows that "mail" button is not disabled for the deal in the "Value Proposition" stage.

C. Change the label for "save" button in Create Page (Standard)
  • Create a Client Script for Create Page (Standard) with onLoad Page event.
  • For details about how to create a Client Script, click here.
  • Enter the following script and save.


var save_btn = ZDK.Page.getButton('record_save');
save_btn.setLabel('Create Deal');


Here is the screenshot showing the "Create Deal" label instead of the "save" label.



Note

        Using Client Script, currently custom buttons can be disabled only in the Detail Page (Standard) and in the List Page (Standard).        


5. Summary

In this post, we have discussed,
  • How to fetch the label of buttons in Client Script
  • How to disable standard and custom buttons based on conditions
  • How to change the label of a button
  • ZDKs and methods available to customize buttons


Kaizen Collection : 

Click here to view our Kaizen Collection. Also, check our previous post Kaizen#114 - Geocoding Leads' Addresses in ZOHO CRM


We hope you found this post useful. We will meet you next week with another interesting topic!

If you have any questions let us know in the comment section.

Cheers!

    Access your files securely from anywhere


            Zoho Developer Community




                                      Zoho Desk Resources

                                      • Desk Community Learning Series


                                      • Digest


                                      • Functions


                                      • Meetups


                                      • Kbase


                                      • Resources


                                      • Glossary


                                      • Desk Marketplace


                                      • MVP Corner


                                      • Word of the Day



                                          Zoho Marketing Automation


                                                  Manage your brands on social media



                                                        Zoho TeamInbox Resources

                                                          Zoho DataPrep 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 Writer

                                                                                    Get Started. Write Away!

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

                                                                                      Zoho CRM コンテンツ






                                                                                        Nederlandse Hulpbronnen


                                                                                            ご検討中の方





                                                                                                  • Recent Topics

                                                                                                  • Zoho Payroll [India Edition] - ICICI Bank Integration

                                                                                                    It seems that ICICI integration with Payroll (and other Zoho apps) has become progressively more difficult this year. It was great until last year but then some apps started requiring a token generated on ICICI website. The whole point of Direct Deposit
                                                                                                  • Issue with EU MArketplace

                                                                                                    Hi It's super frustrating that many CRM / Zoho (whatever) extensions are not available in the EU Market place Example: https://marketplace.zoho.com/app/crm/time-tracker-extension-for-zoho-crm For now, can the team address the extension above, but on the
                                                                                                  • Add an action to set agent as a member of a team in zoho desk

                                                                                                    Hi, Please add an action to zoho flow to set agent as a member of a team in zoho desk (add to a team or remove from a team). Regards, Ram
                                                                                                  • Cant add owner to field update in workflow

                                                                                                    Hi there, Currently when i tried to add owner of the record of the module to the field update, i am unable to. Is there a way to do so?
                                                                                                  • Zoho Books API Limit Is RIDICULOUS!!!!!!!!!!!!!

                                                                                                    The 2,500 API call limit in Zoho Books is about as useful as AOL dialup.  Seriously Zoho, not only can I use up 2,500 API calls in no time with my own app but YOUR OWN STUPID IPAD APP blows through them super fast too, so if any one of my clients wants
                                                                                                  • CRM portal users can now log in using their mobile phone numbers

                                                                                                    Hello everyone! You can now invite portal users using their mobile phone numbers. These portal users will be able to log in using their mobile number and OTP. Templates for these portal-related SMS can be customized as per your needs. This enhancement
                                                                                                  • Zoho CRM: Las últimas novedades de 2024. ¡No te las pierdas!

                                                                                                    ¡Hola, Español Zoho Community! Aunque sabemos que en estas fechas muchos de vosotros estáis ya disfrutando de un merecidísimo descanso, no queríamos acabar el año sin haceros un resumen de las actualizaciones más interesantes de los últimos tres meses,
                                                                                                  • Assistance Required: Custom Model Record Not Visible in Zoho CRM Sandbox

                                                                                                    Dear Team, I hope this message finds you well. I have created a custom model in the Zoho CRM Sandbox account and am currently adding records to it using Python. While I am able to fetch the module data programmatically through Python, I am unable to see
                                                                                                  • Automatic Updates for Zoho Desk Extensions

                                                                                                    Dear Zoho Desk Team, I hope you're doing well. We would like to request the addition of an automatic update feature for Zoho Desk extensions. Currently, updating extensions requires manually searching for updates and clicking the update button. This process
                                                                                                  • Issue with skip_workflow Not Preventing Edit Workflow Trigger

                                                                                                    Hi Team, I am trying to upload a file to a form in Zoho Creator. However, during the upload, an edit workflow is being triggered. I want to prevent this workflow from running, so I have used the skip_workflow parameter as mentioned in the API documentation:
                                                                                                  • Unable to unlink a Bigin account from Zoho Campaign

                                                                                                    I have an old Bigin account that not longer exists but somehow it's still linked by my Zoho campaigns. I am trying to unlink the old Bigin account so I can add my new Bigin account, but when I deny access to the old one, nothing happens (it won't unlink
                                                                                                  • Zoho Upgrade Failure Multiple TImes

                                                                                                    I want to add users to my Zoho CRM. I have carried out the process up to OTP verification, but then it always fails at the confirmation stage. This failure has occurred repeatedly even though the OTP has been successful. Is there a solution to this
                                                                                                  • Import from GoHighLevel to Zoho CRM

                                                                                                    Has anyone been successful with this? I don't want to integrate with GoHighLevel just import/migrate everything over to Zoho
                                                                                                  • No data/body passed to REST server for DELETE by InvokeURL

                                                                                                    Hello Zoho, It seems no data or body of HTTP request is passed to REST server when request type DELETE is used for InvokeURL function. I tried to send DELETE using cURL command and from Python, it worked without problem. The problem occurs only with Deluge's
                                                                                                  • Recurring Bookings

                                                                                                    Will Zoho Bookings ever offer an option to the customer to schedule recurring meetings (unlimited) for the same days/times? Making a client schedule the same days/times for an entire month is a tedious process. I'd like to offer the option upfront to
                                                                                                  • iCloud integration

                                                                                                    I noticed from reading other threads that native integrations with Google Meet and Microsoft Teams are right around the corner. Are there other integrations and fixes to existing integrations coming? There are 2 things keeping me from using Zoho Bookings:
                                                                                                  • How do I associate pricebooks to a customer?

                                                                                                    I setup a few pricebooks, that worked fine. But now the only thing I can do with it, when I enter a quote or sales order, I can select which pricebook to use, but I have to do this product by product every time I add one. Is there a way to connect a pricebook
                                                                                                  • Introducing Dark Mode / Light Mode : A New Look For Your CRM

                                                                                                    Hello Users, We are excited to announce a highly anticipated feature - the launch of Day, Night and Auto Mode implementation in Zoho CRM's NextGen user interface! This feature is designed to provide a visually appealing and comfortable experience for
                                                                                                  • Subforms and automation

                                                                                                    If a user updates a field how do we create an automation etc. We have a field for returned parts and i want to get an email when that field is ticked. How please as Zoho tells me no automation on subforms. The Reason- Why having waited for ever for FSM
                                                                                                  • Pulling Specific Products from Sales Orders in Books to a CRM Record

                                                                                                    We currently process orders directly through our website (woocommerce) as well as through manual sales orders in zoho books. When an order comes through the website, all of the individual products from that order show up in the CRM record of that customer.
                                                                                                  • Functions - How to pass Dynamic Parameters / Arguments?

                                                                                                    I am trying to create a generic function that I can use to update a given field with the name of the user and a given field with a datetime. The purpose of this is to have a history of major actions within the CRM record itself so it is easier to query
                                                                                                  • Locking Certain Feilds

                                                                                                    Hello! I was wondering if there was a way to lock certain fields from being changed until another field had been filled in. For example, my origination has a chain of blueprints that have to be filled in for someone to properly convert from the "Leads"
                                                                                                  • How to void partially paid bill?

                                                                                                    Hello. I have following problem and can't figure out how to solve it. I created a bill from vendor for 180gbp for purchase of some items. It was partially paid (60gbp) and so far so good - 120gbp overdue and items were successfully added to inventory
                                                                                                  • Email Notification to WordPress Blog Subscribers

                                                                                                    You know when a new WordPress blog is published, your subscribers will be notified via email with a link to that blog? Jetpack does it but I'm hoping to get away from it or any other specialized WordPress plugin (like MailPoet), and instead, use a dedicated
                                                                                                  • CRM workflow to trigger Zoho Sign (One)

                                                                                                    Hi,  We have had integration in the past with SignNow in our standard CRM. A onboard would fill out name and address and in turn this would trigger a webhook out of Zoho CRM into Zapier and to SignNow. We've recently upgraded to Zoho One and cannot find anyway to automate the Sign process from CRM to Zoho Sign, is this possible?
                                                                                                  • Lookup field - Can I avoid using advanced search?

                                                                                                    I have a lookup field in my app that has surpassed 500,000 records, now basic search is disabled and I'm forced to use advanced search. That adds multiple steps to what used to be very simple. Before: Select field > Type last digits of product code and
                                                                                                  • Calendar View for Zoho Tickets

                                                                                                    Is there a way to view your tickets with due dates on a calendar view? I can not find a way to merge my Zoho Calendar and Tickets. This would be extremely helpful to my team.
                                                                                                  • Zoho Book - Banking Module - Cash Credit account

                                                                                                    I have a CC account with a bank. I initially added the account as a 'Bank Account' under the banking module in Zoho Books. However, this CC Bank Account is showing as an asset instead of a liability. I have added the account as a credit card account but
                                                                                                  • Zoho Sign Custom Domain

                                                                                                    Any plans for Custom Domain?
                                                                                                  • Multiple date selection

                                                                                                    Hello, we want create app for our company. We need create tasks for our employers. For example - 1 employer have task every Friday the whole year. Second have task every Monday for 6 months. For simple way create Multiple date selection in date form
                                                                                                  • Book project costs to tasks

                                                                                                    Hi all, New to zoho but far from new to this sort of platform. I've been scouring the web for a suitable platform for my growing business. I'm currently using Xero and WorkFlow Max but it lacks a key need. I signed up to zoho projects and books to test
                                                                                                  • SalesIQ-Desk integration update: Seamless helpdesk ticket editing in-chat!

                                                                                                    Did you know you can now edit your desk support tickets within SalesIQ? Happy to announce the latest update to the SalesIQ-Desk integration. Managing your customer support tickets within SalesIQ just got even smoother and better. No more toggling between
                                                                                                  • Been getting this error, every now and then "Get count limit exceeded, please try again after 3 mins"

                                                                                                    it is really annoying.
                                                                                                  • Tags on notes aren't syncing correctly on Android

                                                                                                    I've created notes on the desktop version that have several tags assigned, but on both my Android devices those notes only have ONE of those tags instead of all of them, despite the actual content of the note being correctly synced, and I'm also starting
                                                                                                  • Route Optimizer

                                                                                                    Does Zoho Inventory offer route optimization for our in-house deliveries? It will save us time to manually route our daily orders. Thank you
                                                                                                  • Campaign API Error 2001

                                                                                                    I'm getting a 2001 Error stating "Error in subscription. Please try after some time." I've waited but it continues to persist. I"ve copied and pasted the exact request on the API website yet that doesn't work either.
                                                                                                  • How to list Expenses that have not been matched to a Bank Transaction

                                                                                                    In ZoHo books I use expenses to record invoices I receive. I know I should probably uses Bills for this but Bills was not available in the Free edition I initially used. When I upgraded I contunued to use Expenses. I'm trying to find a way of listing
                                                                                                  • How are you handing birthdays?

                                                                                                    I'm deciding on the best way to handle contact birthdays in my set-up. None of the options seem ideal, so I am interested in how others approach this. The aim is to have a usable ui to track birthday without knowing or requiring the year. I'm currently
                                                                                                  • Fiverr is better than Zoho Partners

                                                                                                    For anyone out there looking for help with Zoho Creator's confusing Deluge, I highly recommend hiring NON ZOHO PARTNERS on Fiverr. I've had much better experiences with those who are NOT certified by Zoho. Almost every single "certified" zoho partner
                                                                                                  • Marketing Automation pour maximiser le ROI : évaluer les performances et optimiser les campagnes

                                                                                                    Le Marketing Automation a transformé la manière dont les entreprises mènent leurs actions marketing, offrant une solution efficace pour simplifier les processus, améliorer la productivité et, surtout, maximiser le ROI. Dans un environnement commercial
                                                                                                  • Next Page