[How-to with Example] Getting field value/data in Client Script from lookup field record

[How-to with Example] Getting field value/data in Client Script from lookup field record

Imagine you have a field you would like to prefill a field based on a value from another record in another module. In this case, we are looking into a scenario where an Asset (custom module) module is being created from a Deal module. Meaning, there is a lookup to the deal module from the asset module.


There is a need to validate a field called ' Business Unit' in the asset record that is being created. This field needs to be the same as it is with the 'Business Unit' value in the deal record of which this asset record looks up to. At the same time, the 'Business Unit' field, having supposedly being prefilled, should be disabled for the users.
Business Unit in Deal record
has to be the same with Business Unit in Asset record
And, if the deal field is null, the 'Business Unit' field in the asset record shall be nulled and reenabled again for users to fill it in manually. The following is the script written and the event is onChange
  1. //checking if there is a value in the lookup field called 'Deal'
  2. if (ZDK.Page.getField('Deal').getValue() != null) {
  3. //getting the value of the 'Deal' lookup field
  4.     var dealRec = ZDK.Page.getField('Deal').getValue();
  5. //getting the Deal record ID
  6.     var dealId = dealRec.id;
  7.     //get business unit value/data from deal record
  8.     var businessUnit = ZDK.Apps.CRM.Deals.fetchById(dealId).Business_Unit;
  9. //we use 'log' to see the value it produces during testing
  10.     log(businessUnit);
  11.     var bu = ZDK.Page.getField('Business_Unit');
  12. //setting the Business Unit to be disabled
  13.     bu.setReadOnly(true);
  14. //prefilling the Business Unit field with the fetched value from Deal record
  15.     bu.setValue(businessUnit);
  16. }
  17. else
  18. {
  19. //if there is no Deal specified, then set the Business Unit field as null and reenable the field
  20.     ZDK.Page.getField('Business_Unit').setValue(null);
  21.     ZDK.Page.getField('Business_Unit').setReadOnly(false);
  22. }
Again this will:
  1. When the Deal field is populated, it will get the Business Unit value from the deal record and prefill it to Business unit field in Asset record.
  2. When Deal field is populated, it will disable the Business Unit field.
  3. When the field is null, it will empty the Business Unit field in Asset record.
  4. When the field is null, it will reenable Business Unit field.
When Deal is populated
This is something that myself as a non-coder is able to do. And being a non-coder, I took it upon myself to share this in a (hopefully) much simpler way so you can understand and start your own journey of using client script.

Hope this is useful for you. As always, good luck!

Nik, aplikasi.us
Zoho Premium Partner

    Access your files securely from anywhere







                            Zoho Developer Community





                                                  Use cases

                                                  Make the most of Zoho Desk with the use cases.

                                                   
                                                    

                                                  eBooks

                                                  Download free eBooks and access a range of topics to get deeper insight on successfully using Zoho Desk.

                                                   
                                                    

                                                  Videos

                                                  Watch comprehensive videos on features and other important topics that will help you master Zoho Desk.

                                                   
                                                    

                                                  Webinar

                                                  Sign up for our webinars and learn the Zoho Desk basics, from customization to automation and more

                                                   
                                                    
                                                  • Desk Community Learning Series


                                                  • Meetups


                                                  • Ask the Experts


                                                  • Kbase


                                                  • Resources


                                                  • Glossary


                                                  • Desk Marketplace


                                                  • MVP Corner




                                                            • Sticky Posts

                                                            • Kaizen #197: Frequently Asked Questions on GraphQL APIs

                                                              🎊 Nearing 200th Kaizen Post – We want to hear from you! 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 #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.
                                                            • Celebrating 200 posts of Kaizen! Share your ideas for the milestone post

                                                              Hello Developers, We launched the Kaizen series in 2019 to share helpful content to support your Zoho CRM development journey. Staying true to its spirit—Kaizen Series: Continuous Improvement for Developer Experience—we've shared everything from FAQs
                                                            • Kaizen #193: Creating different fields in Zoho CRM through API

                                                              🎊 Nearing 200th Kaizen Post – We want to hear from you! 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.
                                                            • Client Script | Update - Introducing Commands in Client Script!

                                                              Have you ever wished you could trigger Client Script from contexts other than just the supported pages and events? Have you ever wanted to leverage the advantage of Client Script at your finger tip? Discover the power of Client Script - Commands! Commands


                                                            Manage your brands on social media



                                                                  Zoho TeamInbox 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

                                                                                                            • Disable field on subform row

                                                                                                              Hi, Is it currently possible to disable a row item on a subform? I was just trying to do something whereby until another value is entered the field is disable but for the deluge scripting interface threw up an error saying such a function is not supported on a subform. Thanks in advance for your help. Shaheed
                                                                                                            • Leads - Kanban view fit to screen

                                                                                                              Hey guys, I created a custom layout for my leads, staged by lead status. I have 10 types of status. In Kanban view I see only 4 columns/stages and need to scroll to the right to see the rest. Is there a way to make columns/stages be displayed all together?
                                                                                                            • Request to Differentiate Auto-Closed WhatsApp Conversations in SalesIQ

                                                                                                              Hi Zoho Support, I’d like to raise a request related to the way WhatsApp conversations are auto-closed in SalesIQ. Every Monday, our Sales team has to manually review each closed WhatsApp conversation from the weekend to identify which ones were automatically
                                                                                                            • Kanban View UI gets a revamp

                                                                                                              Hello everyone, In the coming week you will notice design related enhancements in Kanban View. The UI has been changed and a new option is introduced under Kanban View Settings that allows to change the color of the category headers.  Please, note that the functionality is not changed. These changes will not apply to the Activities and Visits modules. Here are the details of the changes: 1. The column widths have been fixed to 300 px. The records will have a box around them for clear distinction.
                                                                                                            • Can you stop Custom View Cadences from un-enrolling leads?

                                                                                                              I'm testing Cadences for lead nurture. I have set un-enroll properties to trigger on email bounce/unsubscribe, and do NOT have a view criteria un-enroll trigger. However, help documents say that emails are automatically un-enrolled from a Cadence when
                                                                                                            • Issue with Anchor Link on Zoho Landing Page (Mobile/Tablet View)

                                                                                                              Hi Team, I have created a landing page using Zoho Landing Page and added an anchor link to it. The anchor link is working fine on desktop view; however, it does not work properly on mobile or tablet view. I’ve tried debugging this issue in multiple ways,
                                                                                                            • Simplest way to convert XML to a map?

                                                                                                              I've reviewed the help info and some great posts on the forum here by Stephen Rhyne (srhyne). At the moment I'm using XPath to generate a list of xml nodes, iterating through that to fetch the field name/value pairs and adding them to a map (one map for each record in the data). I then convert the row map to a string and add it to a list. Here's the function: list xml.getRecordListFromXML(string xml_data, string ele_name) {     result = List();     // get list of record nodes     rec_list = input.xml_data.toXML().executeXPath("//"
                                                                                                            • Introducing Creator Simplified: An exclusive learning series to enhance your app development skills

                                                                                                              Hey Creators! Welcome to Zoho Creator's new learning series, Creator Simplified. In this series, we'll dive into real-world business use cases and explore how to translate your requirements into solutions in your Creator application. You can also expect
                                                                                                            • [Product update] Updated Data Synchronization Process for QuickBooks - Zoho Analytics Integration.

                                                                                                              Dear QuickBooks integration users, We’re making an important update in the way data is currently synced in your QuickBooks integration within Analytics workspace. What’s changing: Previously, with every data synchronization, Zoho Analytics used to fetch
                                                                                                            • Zoho CRM new calander format cannot strikethrough completed task

                                                                                                              Hi, Recently there is a new format for calendar within Zoho CRM However, found out that a completed task will not cross out or strikethrough like previous format. Without strikethrough, it will be difficult to identify which task is still in Open status.
                                                                                                            • How to edit form layout for extension

                                                                                                              I am working on extension development. I have created all the fields. I want to rearrange the layout in Sigma platform. But there is no layout module in Sigma. How can I achieve this for extensions other than Zet CLI and putting the fields into widget
                                                                                                            • Employees not Users

                                                                                                              Hello, We are a construction company that has +180 employees and most of them are in remote location working onsite with no access to internet. Is it possible that we have data stored for all employees but have only 5-10 users who will be in charge of entering employees data? or do we have to pay for all +180 employees? even though they won't be using the system?
                                                                                                            • Zoho people generatimg pdf

                                                                                                              Hello , now i want to make a customm button in zoho people that is inside a deduction module , that fetches all the records and generate a pdf with a template that i have done in the mail merges template , i was told that i have to upload template on
                                                                                                            • Ability to Filter Alias Mailboxes in Zoho Recruit

                                                                                                              Dear Zoho Recruit Team, I hope you are doing well. We would like to request a feature enhancement regarding the handling of alias mailboxes in Zoho Recruit. Currently, when we connect an alias mailbox (e.g., jobs@domain.com) from our Zoho One account
                                                                                                            • zohorecruit.com career form postcode bug

                                                                                                              Dear, When I select a postcode from the drop down on a zohorecruit.com career form, the street text field is automatically filled with the name of the city, which should not happen. Any idea how I can fix this? Thanks, Bart
                                                                                                            • Office-365-agenda and Microsoft Teams Integration

                                                                                                              Dear, I have a trial version of Zoho Recruit and trying to evaluate the Microsoft Teams Integration in Zoho Recruit. After registering with my Office 365 account and checking the result of the registration/sign-in at https://mysignins.microsoft.com/ (which
                                                                                                            • Delegate Access - Mobile iOS/iPad

                                                                                                              We’re over the moon that delegate access is now available in Zoho Mail as we were nearly ready to switch platforms because of it! Is there a timeline on when delegate mailboxes will be accessible from the iOS and iPad OS applications? Thanks, Jake
                                                                                                            • How to add Connector in developer platform zoho?

                                                                                                              Hi, I am working on creating an Extension, and part of the development is to retrieve Email templates. In my CRM instance I can invokeURL by creating Zoho OAuth connection and get the template. But developer platform does not provide Zoho OAuth or any
                                                                                                            • How to archive Lost/Junk Leads so sales reps don’t see them, but keep them for reporting?

                                                                                                              Hi everyone, In our Zoho CRM we have two Lead Status values: Lost Lead and Junk Lead. What I want to achieve is: When a lead is marked as Lost or Junk, it should disappear from my sales reps’ Lead views (so they only see active leads). At the same time,
                                                                                                            • Zoho CRM Canvas Copy Original Layout

                                                                                                              Hello all, I want to use Canvas to make small changes to certain views, not to make huge changes. Is it possible to copy the original Zoho layout and set-up and start from there? I checked and all I can find are some templates which are far from the original
                                                                                                            • Is there a way to request a password?

                                                                                                              We add customers info into the vaults and I wanted to see if we could do some sort of "file request" like how dropbox offers with files. It would be awesome if a customer could go to a link and input a "title, username, password, url" all securely and it then shows up in our team vault or something. Not sure if that is safe, but it's the best I can think of to be semi scalable and obviously better than sending emails. I am open to another idea, just thought this would be a great feature.  Thanks,
                                                                                                            • Revenue Management: #5 Revenue Recognition in SaaS

                                                                                                              If you're building or running a SaaS business, you've probably encountered this. You get paid upfront for a subscription and a one-time onboarding fee, but you end up with confusion about when to consider it revenue. Can I book all of it now? Should I
                                                                                                            • MS Teams for daily call operations

                                                                                                              Hello all, Our most anticipated and crucial update is finally here! Organizations using Microsoft Teams phone system can now integrate it effectively with Zoho CRM for tasks like dialling numbers and logging calls. We are enhancing our MS Teams functionality
                                                                                                            • Zoho Learn Course Access Issue

                                                                                                              One of the learners in a specific course can't see any lessons. They are registered as both a user and learner for this course in Zoo Learn. What could be the reason?
                                                                                                            • ZOHOLICS Japan 2025 開催のお知らせ(再投稿)

                                                                                                              【コミュニティユーザーの皆さまへお知らせ】 Zoho 最大のユーザーイベント「ZOHOLICS Japan 2025」を9月19日(金)に開催します。 AI活用に関する特別講演、ユーザー事例、Zoho 製品の活用例のご紹介など、Zoholicsならではのセッションをご用意しています。 Zoho コミュニティ開催のMeetupとはまた違った雰囲気のイベントです。 ご都合のつく方はお気軽にご参加ください✨ 詳細はこちら https://events.zoho.jp/zoholics2025#/?affl=forumpost2
                                                                                                            • Phone Number format for Bulk Upload via csv for Zoho Sign

                                                                                                              What is the phone number format that we need to use for a bulk recipient upload via csv in zoho sign, should the country code be included for ex if its US should it be +18889007865 ior 18889007865 or without country code 8889007865? the sample csv provided
                                                                                                            • Filter Page Elements By Selectable Date Range

                                                                                                              I have created a basic Page that will serve as a client dashboard with elements that will provide simple counts & sums of data in reports. There are no reports or forms added to the page, just elements. It currently functions as needed, but shows the
                                                                                                            • Can’t Enter my Notebook is Locked

                                                                                                              I’ve been using Notebook for taking notes at my college for a month and I never signed in and I never established a password. Today I tried to enter the app after the update and it asked me for a password. I need to access to my notes urgently and I can’t
                                                                                                            • Send Email Directly to Channel

                                                                                                              Hi, We are coming from Slack. In Slack each channel has a unique Email address that you can send emails too. I currently forward a specific type of email from my Gmail InBox directly do this channel for Verification Codes so my team doesn't have to ask
                                                                                                            • Secure your external sharing process with OTP Authentication

                                                                                                              For any business, it's crucial to share files externally in a way that is both secure and controlled. Let's say you want to share confidential data with your partners and vendors. You must ensure that only your intended recipients can access the shared
                                                                                                            • Items attribute questions

                                                                                                              Many of my items have attributes, such as size and color. How can I add new fields to the "New Items" screen to capture that in my Purchase Orders, Items, and Sales Order pages? I only see these attribute fields when adding an Item Group. Also, on the
                                                                                                            • Is there a way to search mail for items you haven't yet responded to?

                                                                                                              I'm trying to create a search to show emails that haven't been responded to and that have also been assigned a tag or label. Is there a way to search for the inverse of replied?
                                                                                                            • Zobot and Sales IQ

                                                                                                              What will happen to the Zoho Sales IQ being integrated to the website after creating the Zobot on the website too
                                                                                                            • Subtotals per Header

                                                                                                              Hey, we would like to display subtotals per header in our invoices:
                                                                                                            • Zoho Cliq not working on airplanes

                                                                                                              Hi, My team and I have been having this constant issue of cliq not working when connected to an airplane's wifi. Is there a reason for this? We have tried on different Airlines and it doesn't work on any of them. We need assistance here since we are constantly
                                                                                                            • upgrade storage

                                                                                                              how to upgrade my storage
                                                                                                            • Linking items from books and subscription

                                                                                                              Linking books and subscription It is a pity that it is not possible to associate with a product an article present in ZohoBooks This would make it possible to manage products composed of a nomenclature of articles of books
                                                                                                            • Add the ability to view number of hours planned for a workorder while in the Dispatch Console

                                                                                                              Hi Zoho, When dispatching a work order through the Dispatch Console, there's currently no way to view the number of planned hours for the service tasks associated with that specific work order. Having to click into the details each time to check planned
                                                                                                            • Uploading Files from uploads api

                                                                                                              I tried uploading the image from the API call but its giving me unauthorized error even i have given valid token in header. After uploading i need that id to pass in create ticket api uploads but its not uploading that file. Please help me out in th
                                                                                                            • Categorize Items with Item Headers

                                                                                                              Hello customers, Did you ever want to classify items based on specific categories to help your customers understand your invoice better? With the new Item Header feature, you can easily categorize items in your invoices and estimates and give them a common title.  Item Headers are available in the Invoices, the Recurring Invoices and the Estimates module. It can be carried forward from estimates to invoices at the time of converting the estimates.  To add an item header: Go to the Estimates, Invoices
                                                                                                            • Next Page