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

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

いつもお世話になっております。
今成様や西尾様、松井様にはお話しておりますが、先日開催された「カスタム関数マスター講座 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

    • How to Delete Personal Account Linked with My Mobile Number in past or by someone else

      How to Delete Account Created with My Mobile Number in past or by someone else This is creating issues in making or sync with my credentials mobile and email address..
    • Enable / show scroll bar when Mega Menu is opened

      Hey there I am using the mega menu add-on and experience a "flicker" whenever the mega menu opens. The reason is, that the scrollbar, which has a width of a few pixels, stops showing when the mega menu opens. As the scrollbar disappears the whole page
    • Restore lost Invoice!

      Some time ago I tried to Upgrade from Invoice to Books. I not upgraded and staid n Invoice. Now i tried again and first i deleted the old trial of books. But now all is gone, PLEASE HELP!! i have no backup and i have to have at least 7 years data retention by law. 
    • Zoho Desk Down

      Not loading
    • lookup and integrated forms

      I might be misunderstanding things but I wanted to integrate our zoho crm contacts into creator. I imagined that when I used the integration it would mirror into creator. It did brilliant. BUT We have a ticket form in creator that we want to use a lookup
    • Partially receive PO without partial Bill?

      Most of our inventory is pre-paid. Let's say we purchase 30 pieces of 3 different items for a total of 90 pieces. It is common for our supplier to send us the items as they are ready. So we will receive 30 pieces at a time. How can I partially receive
    • 2 users editing the same record - loose changes

      Hello, I'm very new to Zoho so apology if this has been addressed somewhere i can't find. I have noticed the following: If we have 2 users put an inventory item in edit mode at the same time: say user1 click on edit and user2 while user1 is still in edit,
    • How to get the Dashboard page to be the first page when you open the app

      So when it opens on a tablet or phone it opens on the welcome page, thanks.
    • How I set default email addresses for Sales Orders and Invoices

      I have customers that have different departments that handle Sales Orders and Invoices. How can i set a default email for Sales Orders that's different than the default email for Invoices? Is there a way I can automate this using the Contact Persons Departments
    • Adding hyperlinks in CRM emails time automatically

      It may just be me, but when I am writing an email to a lead, I find inserting a hyperlink very time consuming. Granted, I can use templates but there are a ton of scenarios where I might want to put a link in to an website that wouldnt require me to go though the effort of creating a template.  Ideally, the crm would identify that I that a string of text is a URL and insert the hyperlink automatically, just like microsoft outlook or gmail. Has anyone else had this same experience and found a way
    • Notes Attachments

      Two things it would be nice to have the attachment size the same as the attachments sections and it would be nice to be able to attach links like you can in the attachments section. Thank you
    • Zoho Sheet - Desktop App or Offline

      Since Zoho Docs is now available as a desktop app and offline, when is a realistic ETA for Sheet to have the same functionality?I am surprised this was not laucned at the same time as Docs.
    • Formula fields not refreshing until page is reloaded

      I need help/advice about the formula fields and how I can refresh the information in real-time. We have two formula fields on our deals page which show calculated prices: One formula is in a subform which calculates the subform total + 1 other field amount
    • How can I setup Zoho MCP with Chat GPT

      I can set up custom connections with Chat GPT but I cat an error when I try to set it up. The error is: "This MCP server can't be used by ChatGPT to search information because it doesn't implement our specification: search action not found" Thoughts?
    • Export Invoices to XML file

      Namaste! ZOHO suite of Apps is awesome and we as Partner, would like to use and implement the app´s from the Financial suite like ZOHO Invoice, but, in Portugal, we can only use certified Invoice Software and for this reason, we need to develop/customize on top of ZOHO Invoice to create an XML file with specific information and after this, go to the government and certified the software. As soon as we have for example, ZOHO CRM integrated with ZOHO Invoice up and running, our business opportunities
    • API ZOHO CRM Picket list with wrong values

      I am using Zoho API v.8. with python to create records in a custom module named "Veranstaltung" in this custom module I've got a picket list called "Email_Template" with 28 Values. I've added 8 new values yesterday, but if I try to use on of those values
    • Group Emails

      I have synced Zoho CRM to Campaigns but there are certain email not synced. showing it is Group Emails, but this email ids belongs to different individuals. please provide a solution as i nedd to sync the same.
    • Enable Password Import option in ulaa browser

      Dear Ulaa Team, I noticed that the Ulaa Password Manager currently offers an option to export passwords, but not to import them. This limitation poses a challenge for users like me who have stored numerous credentials in browsers like Chrome. Manually
    • "Is Zoho CRM customer" vs "Is linked with Zoho CRM"

      Recently while building a Flow, I was setting up a Decision action following a Zoho Invoice Fetch record action. There were 2 choices that I had not seen as something I could manually action in Zoho Invoice: "Is Zoho CRM customer" and "Is linked with
    • Client Script | Update #13 - Introducing ZRC: Simplified HTTP request library

      Hello Developers! Are you tired of juggling different methods to make API calls? Are you confused with multiple syntaxes and version restrictions? Have you ever wished for one simple way to make all API calls in CRM? We heard you :) Here comes ZRC (Zoho
    • Selection Filed for Data Export section

      Hi FSM Team, I hope you are all doing well. I would like to share an idea for future development based on my experience. Currently, in FSM, we can only download up to 5,000 records at a time. If the development team could add a selection option to choose
    • Text wrap column headers in reports?

      Is it possible to auto wrap column headers so that a longer multi-word header displays as two lines when the column is narrower than the width of the header title?
    • What if I dont see contacts on the left side list

      My CRM does not show the contacts tab. In order to create list this is needed and I cant find it.
    • Comments Vs. Replies

      I'm curious as to the difference between a "Reply" and a "Comment" on a ticket. It appears that "Replies" are what's used to determine response time SLA's and there are also used to automatically re-open tickets. I'm just trying to understand the key differences so I can educate both our clientele and our back-end users on which function/feature to use to better improve the ticket lifecycle. If anyone has any insight it would be appreciated. Thanks!
    • Transitioning to API Credits in Zoho Desk

      At Zoho Desk, we’re always looking for ways to help keep your business operations running smoothly. This includes empowering teams that rely on APIs for essential integrations, functions and extensions. We’ve reimagined how API usage is measured to give
    • Add Custom Reports To Dashboard or Home Tab

      Hi there, I think it would be great to be able to add our custom reports to the Home Tab or Dashboards. Thanks! Chad
    • Resetting auto-number on new year

      Hi everyone! We have an auto-number with prefix "D{YYYY}-", it generates numbers like D2025-1, D2025-2, etc... How can we have it auto-reset at the beginning of the next year, so that it goes to D2026-1? Thanks!
    • Microsoft Phone Link

      Does anyone know if you can use Microsoft Phone Link to make calls through Zoho?
    • Voip Phone system that integrates with Zoho

      Just checking to see if anyone could tell me what phone system they are using with Zoho that is on the list of systems that integrate with Zoho.  I use Vonage and have been with them for quite a few years but their service has really gone down hill and
    • Removing Related Modules Lookup Fields Assignment / Relationship

      Issue: When creating a related list, I accidently selected module itself creating a circle reference. See attached. Situation: I wish to relating a custom module called "Phone Calls" to Leads and Contacts. Outcome: 1) I either want to remove the this
    • [Product Update] TimeSheets module is now renamed as Time Logs in Zoho Projects.

      Dear Zoho Analytics customers, As part of the ongoing enhancements in Zoho Projects, the Timesheets module has been renamed to Time Logs. However, the module name will continue to be displayed as Timesheets in Zoho Analytics until the relevant APIs are
    • Kaizen #210 - Answering your Questions | Event Management System using ZDK CLI

      Hello Everyone, Welcome back to yet another post in the Kaizen Series! As you already may know, for the Kaizen #200 milestone, we asked for your feedback and many of you suggested topics for us to discuss. We have been writing on these topics over the
    • Can you prevent closing Ulaa window when the last tab is closed (inadvertently)?

      Most browsers have started to bring this feature in to prevent closing their windows when the last tab is closed (inadvertently). I hope Ulaa should get this in too.
    • Seriously - Create multiple contacts for leads, (With Company as lead) Zoho CRM

      In Zoho CRM, considering a comapny as a lead, you need us to allow addition of more than one contact. Currently the Lead Section is missing "Add contact" feature which is available in "Accounts". When you know that a particular lead can have multiple
    • can I link a contacts to multiple accounts

      can I link a contacts to multiple accounts
    • Rotate an Image in Workdrive Image Editor

      I don't know if I'm just missing something, but my team needs a way to rotate images in Workdrive and save them at that new orientation. For example one of our ground crew members will take photos of job sites vertically (9:16) on his phone and upload
    • Free webinar! Digitize recruitment and onboarding with Zoho Sign and Zoho Recruit

      Hello, Tired of being buried in onboarding paperwork? With the integration between Zoho Sign and Zoho Recruit, a powerful applicant tracking system, you can digitize and streamline the entire recruitment and onboarding process, all from one platform.
    • is it possible to add more than one Whatsapp Phone Number to be integrated to Zoho CRM?

      so I have successfully added one Whatsapp number like this from this User Interface it seems I can't add a new Whatsapp Number. I need to add a new Whatsapp Number so I can control the lead assignment if a chat sent to Whatsapp Phone Number 1 then assign
    • Open Activities view.

      I really like the new views for the open and closed activities inside the deals. But when you are in the tab view instead of the column view you can only complete and edit the open activity there isn't the 3 dot option to be able to delete the activ
    • Potentially Outdated and Vulnerable Chromium Engine Installed by Ulaa Browser Installer

      I just installed Ulaa Browser a few minutes ago. Whats My Browser page shows I am using an outdated Chromium engine meaning I might be vulnerable for security exploits that might have got fixed in the new version.
    • Next Page