クライアントスクリプトを使用して項目の入力必須化を行いたい

クライアントスクリプトを使用して項目の入力必須化を行いたい

いつもお世話になっております。
今成様や西尾様、松井様にはお話しておりますが、先日開催された「カスタム関数マスター講座 Vol.4」で、宿題として取り組んだもののうまくいかなかったクライアントスクリプトを投稿させていただきます。


【取り組んだテーマ】
自社の商談タブに設置しているサブフォームの項目「販売金額総額(税別)」で何らかの金額更新があったら、項目「外注総額_」をクライアントスクリプトで入力必須の項目にする。
 必須化の条件は、「販売金額総額(税別)」で「0」円よりも大きい数字(=1以上)が反映されたときとする。

(サンドボックス環境の商談タブ画面(データはダミーです))



【参照した情報と記述したコード】

(使用項目とAPI名)
・販売金額総額(税別)Quote_Amount
・外注総額_ TotalOutsourcing1

●テストコードその1

let quote_amount = ZDK.Page.getField('Quote_Amount'); // サブフォームの「販売金額総額(税別)」('Quote_Amount')をquote_amountと定義する
let quote_amount_value = ZDK.Page.getField(); // そのquote_amountの値をquote_amount_valueと定義する
log(quote_amount_value); // quote_amount_valueをログに出す?

let total_outsourcing1 = ZDK.Page.getField('TotalOutsourcing1'); // 外注総額_('TotalOutsourcing1')をtotal_outsourcing1と定義する

quote_amount.setValue('Quote_Amount'); // quote_amountに「販売金額総額(税別)」('Quote_Amount')の値をセットする?

if (quote_amount_value > 0) {   // もし、quote_amount_valueに0よりも大きい数字(=1以上)が入っていたら、
    total_outsourcing1 = ZDK.Form.Field.Mandate('TotalOutsourcing1'); // total_outsourcing1を入力必須項目とする
    total_outsourcing1.showError("「外注総額_は必須です。発生しない場合は0を入力してください");   // さらにtotal_outsourcing1にエラーメッセージを出す
} else {  // もし、quote_amount_fieldに0よりも大きい数字が入っていなければ(=0)、
    ZDK.Client.showMessage("見積書を作成する場合は「商談から見積書を作成する」ボタンをクリックしてください", { type: "info" });   // 画面に情報メッセージを出す ※本当は「何もしない」という処理を設定したい。
}

●テストコードその2 

var quote_amount_field = ZDK.Page.getField("quote_amount");  // サブフォームの「販売金額総額(税別)」("quote_amount")をquote_amount_fieldと定義する
quote_amount_field.setValue("quote_amount");  // quote_amount_fieldには、サブフォームの「販売金額総額(税別)」("quote_amount")の値を入れる
var total_outsourcing1_field = ZDK.Page.getField("TotalOutsourcing1");   // 「外注総額_」("TotalOutsourcing1")をtotal_outsourcing1_fieldと定義する

if (quote_amount_field > 0) {   // もし、quote_amount_fieldに0よりも大きい数字(=1以上)が入っていたら、
    total_outsourcing1_field = ZDK.Form.Field.Mandate('TotalOutsourcing1');    // total_outsourcing1_fieldを入力必須項目とする
    total_outsourcing1_field.showError("「外注総額_は必須です。発生しない場合は0を入力してください");    // さらにtotal_outsourcing1_fieldにエラーメッセージを出す
} else {    // もし、quote_amount_fieldに0よりも大きい数字が入っていなければ(=0)、
    ZDK.Client.showMessage("見積書を作成する場合は「商談から見積書を作成する」ボタンをクリックしてください", { type: "info" });   // 画面に情報メッセージを出す ※本当は「何もしない」という処理を設定したい。
}


(クライアントスクリプトのエディター画面)
*テストコードを2種類記述していますが、一方をコメントアウトして、それぞれでプレビューして挙動を確認しました。


*なお、岸本様のサンプルに「サブフォームの総額は項目変更の処理ができないため、ページが変わったらの条件で指定」との記載があったため、それに従い「ページの処理」に対して設定しています。(編集画面でのonChange)

【結果】
エディターツール上でエラーはカウントされないが、特に挙動もしない。

----------------------------

以上でございます。

Javascript未経験であるため、まずvarやletの使い分けなども理解できておらず、コメントで書き足しているコードの解釈なども誤っている箇所があるかと存じますが、挙動しない要因がどこにありそうか、ご意見をいただけますと幸いです。


何卒よろしくお願いいたします。





        • Recent Topics

        • Using files from Zoho CRM in Gemini/ChatGPT/Claude

          Hi all, I’ve got subscriptions to Gemini and a few other AI tools which I use for tasks like data enrichment, email composition, etc. In our workflow, we often receive various documents from clients — such as process workflows, BRDs/requirement documents
        • Enhancements to the formula field in Zoho CRM: Auto-refresh formulas with the "Now" function, stop formula executions based on criteria, and include formulas within formulas

          Dear Customers, We hope you're well! By their nature, modern businesses rely every day on computations, whether it's to calculate the price of a product, assess ROI, evaluate the lifetime value of a customer, or even determine the age of a record. With
        • Maximum file limit in zoho people LMS

          Dear Team, I am having approximately 4.9 GB of material, including PPTs and videos for uploading in zoho people LMS course. May I know what is the maximum limit limit for the course files Thanking you, With regards, Logeswar V Executive _ Operations
        • Displaying related quotes in sales order and back

          Hi, My colleague liked to see to which sales orders, the quote has been converted. Quote shows Invoices, but not SO. Same, they would like to see the quotes in the sales order, as they can see invoices, packages, shipment, How can we achieve this ? Thank
        • Dynamically prefill ticket fields

          Hello, I am using Zoho Desk to collect tickets of our clients about orders they placed on our website. I would like to be able to prefill two tickets fields dynamically, in this case a readonly field for the order id, and a hidden field for the seller
        • Optimize your Knowledge Base for better visibility by allowing search engine crawling and indexing

          All you need to know about no-follow and no-index in KB. What are article crawlability and indexability? Crawlability and indexability are vital for making an article visible and accessible to search engines. When a search engine crawls an article, it
        • Has anyone created a public ASAP Guide that I can check out?

          I am thinking of adding an ASAP guide to my web application, but I have noticed that the ASAP widget itself can be really slow to load sometimes. Has anyone created a public ASAP Guide that I can check to see how performant it is? I don't want to spend
        • Zoho Desk Partners with Microsoft's M365 Copilot for seamless customer service experiences

          Hello Zoho Desk users, We are happy to announce that Zoho Desk has partnered with Microsoft's M365 to empower customer service teams with enhanced capabilities and seamless experiences for agents. Microsoft announced their partnership during their keynote
        • What’s New in Zoho Analytics – September 2025

          Hello Users!! In this month’s update, we’re raising the bar across multiple touchpoints, from how you bring in data, plan and track projects to how you design and brand your dashboards. We’ve added the all-new Gantt chart for project visualization, expanded
        • Zoho MCP has no tools for Creator or 3rd Party Apps?

          I don't see a Zoho MCP community forum so putting this here. Two big problems I see: 1) Although Zoho advertises "over 950 3rd party apps" as available through their MCP, when I go to "Add Tools" there are ZERO 3rd party apps available to choose from.
        • Zoho Forms - Zoho Drive connection - Shared Drives not supported

          Hello i am stuck with Google Drive Connection There is no supported shared drives Connection is not support shared drives boolean Query Parameters - supportsAllDrives=true&supportsTeamDrives=true to activate fetch files from the shared drives. Ahat need
        • Can't create package until Bill created?

          I can't understand why we cannot create a package until a Bill is created? We are having to created draft Bills to create a package when the item is received, but we may not have received a Bill from the supplier. Also, Bill # is required, but we normally
        • Whats the Time out Limit for API Calls from Deluge?

          Hi Creator Devs, We are making API calls to third party server via Deluge. Getting this error message: Error at line : 24, The task has been terminated since the API call is taking too long to respond. Please try again after sometime. Whats the default
        • Community Digest Agosto 2025 - Todas las novedades en Español Zoho Community

          ¡Hola, Zoho Community! Agosto llega a su fin y septiembre nos trae aire fresco a la comunidad: más inteligencia con IA, actualizaciones que elevan la productividad y la recta final hacia Zoholics España 2025. Aquí tienes lo más destacado del mes para
        • Tip #3: How to change your booking page language

          Displaying your booking page in your target audience's language can greatly increase customer satisfaction. By speaking their language, you will help customers feel more comfortable scheduling with you and create a stronger connection with them. Let's
        • How can I optimize a Zoho Site page for SEO when embedding external menu or restaurant links?

          Hi everyone, I’m experimenting with building small content hubs on Zoho Sites and want to make sure I’m doing it in an SEO-friendly way. For example, I tried creating a page that highlights restaurant menu items and linked out to a resource like this:
        • Diff signature for compose new email and replies

          Hi,   How do i have different signature for replies and new emails. its inconvenient to have one large signature for replies. Usually on Outlook we have the option to keep separate signatures for new emails and for replies.
        • Zoho Website Site Speed Up & Setting

          We are experiencing slow loading speeds on our Zoho website and would like assistance in optimizing its performance. Kindly review the site and suggest or implement necessary improvements to enhance speed, especially related to: > Caching mechanisms >
        • Clickjacking: Zoho Vault's Response

          Issue: Password manager browser extensions are found to be vulnerable to clickjacking security vulnerabilities that could allow attackers to steal account credentials, TFA codes, and card details under certain conditions. Reported by: Marek Toth, Independent
        • No option for pick up in Zoho Books / Inventory but yes on commerce

          Is it planned to release soon on books/inventory?
        • Accessing Zoho form enteries via API

          Hi As a user I can view enteries to a form at: https://forms.zoho.com/<myOrganisation>/report/<myReportName>/records/web How do I access these entries via API? I don't have any problem with scope and getting tokens. But I have no idea what the API call
        • Zoho Books - France

          L’équipe de Zoho France reçoit régulièrement des questions sur la conformité de ses applications de finances (Zoho Books/ Zoho Invoice) pour le marché français. Voici quelques points pour clarifier la question : Zoho Books est un logiciel de comptabilité
        • Blueprint Issue - Being able to set a subform field as mandatory

          I'm creating a blueprint. My record involves a subform which is only shown once field is set but the field gets set in step two of the process. My problem - I can't save the record as the subform field is set to mandatory - If I unset the mandatory field,
        • Blueprint - Mandatory file upload field

          Hi, File upload (as we as image upload) field cannot be set as mandatory during a blueprint transition. Is there a workaround? Setting attachments as mandatory doesn't solve this need as we have no control over which attachments are added, nor can we
        • Zoho Books - Include Quote Status in Workflow Field Triggers

          Hi Zoho Books team, I recently tried to create a Workflow rule based on when a Quote is Accepted by the customer. This is something which I thought would be very easy to do, however I discovered that Status is not listed as a field which can be monitored
        • Zoho Books - Show Related Sales Orders on Quotes

          Hi Books team, I've noticed that the Quotes don't show show the related Sales Order. My feature request is to also show related Sales Orders above the Quote so it's easy to follow the thread of records in the sales and fulfilment process. Below screenshot
        • Add VAT/Tax line to bank adjustments

          When categorising transactions and matching bank feeds with transactions such as customer payments, we use the "Add Adjustment" to add things like fees/bank fees. It would be useful to choose a VAT/Tax rate here. Whilst there is a bank charges option when adding a payment, this goes into the default bank charges account. We use the adjustments so that we can choose the account and separate our fees. We use different card providers and Worldpay charges VAT so we are stuck. We cannot integrate with
        • New Menu Layout Feedback

          I'd really like to see the banking item back on the top of the menu. I'm sure part of it is just because that's what I'm accustomed to. However, for a bookkeeping program, I think there's a logic to having banking be on top. Not a giant issue, but something
        • How to use Rollup Summary in a Formula Field?

          I created a Rollup Summary (Decimal) field in my module, and it shows values correctly. When I try to reference it in a Formula Field (e.g. ${Deals.Partners_Requested} - ${Deals.Partners_Paid}), I get the error that the field can’t be found. Is it possible
        • Form Accessibility

          Hi, is there an update on the accessibility standard of Zoho forms? Are the forms WCAG 2.1 AA compliant? 
        • Cannot schedule report delivery

          The only 'send option' available when exporting reports is 'immediately' The option to schedule the report is missing.
        • adding attachment in sendmail script where attachment is in a CRM field

          Hi all, I have a custom field of type 'File Upload' in one of my modules in my CRM. I want to include the file in that field as an attachment to an email - which is done from a button on  the 'Results' module. I have created a script and a button to initiate an email from that module. The Deluge scripting window has allowed me to add arguments for all the fields I need to use except for the one file upload type field. My script currently looks like the below (content of the email omitted). As you
        • [Free Webinar] Learning Table Series - AI-Enhanced Insurance Claim Management in Zoho Creator

          Hello Everyone! We’re excited to invite you to another edition of Learning Table Series, where we showcase how Zoho Creator empowers industries with innovative and automated solutions. Struggling with lengthy claim processes, a lack of visibility into
        • Zoho Suite is very slow

          Since today Zoho is incredibly slow over all applications! What's going on?
        • Not sure how to use credits to my account

          Hi I have a $50 credit to my account. I'm just wondering how I can apply that to either a current invoice or to try a new service. Any advice would be great, thanks. Kind Regards Chris
        • Control who sees Timeline and Interactions in Zoho CRM through Profiles

          The feature has been enabled for all DCs (except US, EU, and IN DCs). We will be rolling it out to the other DCs in the upcoming days. Dear All, In a CRM, not all users would require access to the history of a record. For instance, a Marketing Operations
        • Zoho Desk Integration - Add the option to send the estimate from the Zoho Desk Ticket Integration

          Hi, Currently in the Zoho Desk integration, the user is able to create an estimate from a ticket, once the estimate is created the user can see the estimate under the ticket (see screenshot below), but is not able to send that estimate from Zoho Desk.
        • Utilisation de Zoho en conformité avec l’article 286 du Code général des impôts (CGI)

          Cher(e) client(e), Conformément à l’article 286 du Code général des impôts (CGI) impose aux entreprises assujetties à la TVA d’utiliser des systèmes de caisse ou de gestion commerciale certifiés lorsqu’elles enregistrent des ventes à des particuliers.
        • Issue showing too many consultations in my workspace link.

          Hi Team, I’ve set up two Workspaces to track meetings from different sources. So far, this has been working well, and the two Workspaces are differentiated without any issues. However, when I navigate to Consultations and share the link to my personal
        • 👋 Welcome to the Zoho MCP Community

          Hello all, glad to have you here! This is your space for everything AI agents, MCP tools, and intelligent business apps. This community is for you — developers, partners, creators, and businesses exploring how agents can transform work. Whether you’re
        • Next Page