Kaizen# 83: Get input via pop-up and show/hide fields in Client Script
Hello everyone!
Welcome back to another Kaizen post.
In this post, let us discuss the following use cases.
A. How to get input via a pop-up
1. Requirement
Consider that the requirement is to display a pop-up whenever a Salesperson changes the "Stage" of the deal. The Salesperson should be able to add comments in that pop-up. This comment should be populated to the field "Description" along with the name of the "Stage" and it should keep appending the comments whenever there is a change in Stage.
Solution
The script should execute whenever the salesperson selects the field "Stage". So create a Client Script on Create Page of the Deals module.
- Go to Setup > Developer Space > Client Script. Click +New Script.
- Specify the details to create a script and click Next.
- Enter the following script and click Save.
var notes_pop_up = ZDK.Client.getInput([{ type: 'text', label: 'Comments' }], 'Deal', 'OK', 'Cancel'); var notes_field = ZDK.Page.getField("Description"); if (notes_field != null) { var desc = notes_field.getValue() + " " + value + "- " + notes_pop_up +","; notes_field.setValue(desc); } |
- The getInput() ZDK enables you to show a pop-up on screen. You can add fields with labels in this pop-up. The field that appears in this pop-up is a pseudo field and is not a real field in the Deals module. It will appear only when Client Script executes and you can use it in the script. Such pseudo fields are highly beneficial when you want to manipulate/calculate data based on user input as it does not affect the module's field limits of Zoho CRM.
Syntax of getInput() :
- getInput(options, heading, accept_message, reject_message) → {Object}
Parameters:
- options - Input options (Maximum number of options is 7).
- heading - Heading of the pop-up.
- accept_message - Text for accepting message.
- reject_message - Text for rejecting message.
Here is how the Client Script works,
B. How to hide and show fields using Client Script
1. Requirement
To hide the field "Expected Revenue" when the status of the Deal is "Needs Analysis".
Solution
This script should run whenever the salesperson updates the field "Stage". So create a Client Script on Edit Page of the Deals module.
- Go to Setup > Developer Space > Client Script.
- Click +New Script.
- Specify the details to create a script and click Next.
- Enter the following script and click Save.
var stage_field = ZDK.Page.getField('Stage').getValue(); log(stage_field); var field_obj = ZDK.Page.getField('Expected_Revenue'); if (stage_field == 'Needs Analysis') { field_obj.setVisibility(false); } else { field_obj.setVisibility(true); } |
Syntax
Parameters
- value - visibility attribute of the field input(true/false)
Here is how the Client Script works.
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.
Click here for more details on Client Script in Zoho CRM.
Happy Scripting!
Related Links
Access your files securely from anywhere
Zoho Developer Community
Deliver unforgettable customer experiences
Deliver unforgettable customer experiences
New to Zoho Marketing Plus?
Everything you need to run your marketing
New to Zoho Marketing Plus?
Everything you need to run your marketing
Zoho Desk Resources
-
Desk Community Learning Series
-
-
-
-
-
-
-
-
-
Sticky Posts
Focus Group Webinar - Streamline Record Creation with Wizards
Hi there, With all the time your users spend on record creation, do you feel like they have the most seamless experience while doing it? For different types of records or those with a LOT of fields, do your users spend time navigating to enter data repeatedly?
Notes and Attachments visibility can now be restricted based on profiles
Dear All, We hope you're well! We are here with a quick update about Notes and Attachments profile permissions. In the past, a record's Notes and Attachments were visible by default to all users with record access. However, as notes and attachments can
Identify and prioritize profitable deals: Zoho CRM Forecasts help users focus on revenue-driving opportunities
Post moderated on: 7th November: Release update: This feature is now available for users in all DCs. Dear Customers, We hope you're well! At any given time, a sales rep handles multiple deals, each progressing at its own pace. But not all deals will succeed—some
Gain control over record sharing with portal users through our new enhancement: criteria-based data exposure
Dear Customers, We hope you're well! Portals is a self-service avenue through which your clients can access and manage their direct and related data in Zoho CRM. This empowers them to be more independent and enables them to experience a sense of transparency
Context and convenience just got better with Zia's email intelligence
Dear Customers, We hope you're well! We are in 2024, and email as a tool is only getting more powerful each day. While it enables seamless daily correspondences, we are here with a set of abilities that will enhance your user experience and save several
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 Campaigns Resources
Zoho CRM Resources
Zoho Show Resources
Writer Get Started. Write Away!
Writer is a powerful online word processor, designed for collaborative work.