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

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

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

    • Export from Contacts module to Products module in Zoho CRM

      Good afternoon, I would like to send a number of contact info from the Contacts module into the customized module (tickets to an event) in one operation. I have selected several contacts in the Contact module (people who I have labelled as people I want
    • Zoho Commerce

      Hi, I have zoho one and use Zoho Books. I am very interested in Zoho Commerce , especially with how all is integrated but have a question. I do not want my store to show prices for customers that are not log in. Is there a way to hide the prices if not
    • Can’t receive emailI c

      I have generated a basic for but when I submit it I don’t get a email, I’ve been in the settings and tested me email, all appears correct, can you please help me
    • Data Capture for Historical Activity (Especially One Lead Downloading Variois reports without Overwriting the info)

      Is there a better way in Zoho CRM to capture and archive a lead’s historical activity—specifically whenever they download reports—so that the data is stored without being overwritten?”
    • Client Script - Updating Field Value in Detail Page of a Lead

      Hello, I'm trying to use Client Script To enrich some data of the Lead when one of my User fill the "City" field in the detail page of the Lead. This is my Script: log (value); var response = ZDK.Apps.CRM.Functions.execute("getInfoCitta", { "nomeCitta":
    • Auto shapes in Zoho sheet.

      Does Zoho sheet supports inserting auto shapes (rectangle, circle...). I did not see any option to do so.  If its not supported currently, is there any plans on bring in this features. Any timelines ?
    • I Can't Clone Webinar that I Co-Organize

      How do i get our account admin to give me permission to clone our webinars? I am a co-organizer
    • How to get the call recording external ID via desk API

      I have enabled phonbridge integration with Zoom Call. I am trying to access the call recording in Zoom by calling Zoom API. I have built a Desk workflow to trigger on a new call, to call a custom function. when calling the API, the response doesn't contain
    • Can't View Project Names in Mobile App

      I can't view project names on PO's in the app, nor can I add that as a viewable PDF field in inventory on the computer. I've attached screenshots showing that in the mobile version whether you are on the PO, editing the PO, or viewing the PO line items,
    • How do you print a refund check to customer?

      Maybe this is a dumb question, but how does anyone print a refund check to a customer? We cant find anywhere to either just print a check and pick a customer, or where to do so from a credit note.
    • Notebook

      I have purchased the monthly pro subscription of Notebook. But it does not support my XP-Pen to write something in it. So it is not useful to me. Hence I am requesting you to help me to discontinue this subscription.
    • Domain Mapping & Image Publishing Issues on Zoho Sites

      Hello, I am facing two issues with my Zoho Sites account: 1. Images not visible after publishing. 2. Domain mapping error: "Domain already exists". I am a paid customer. Please connect me with Live Chat Support or Zoho Assist so I can show my issue
    • Prevent duplicate with custom fields?

      I was wondering something about custom field/custom modules in Zoho Desk. For some reason you can make a custom field mandatory but not unique? For example, if I create a custom module to manage equipment and renewal and make a field serial number no
    • Two currencies

      More and more I am finding that internattional payments' fees are unpredictable. I would like, on my invoices that are in a foreign currency (eg. USD$ or EUR€) for there to be a GBP£ TOTAL display alongside the invoice's currency total. This would make
    • Generate leads from instagram

      hello i have question. If connect instagram using zoho social, it is possible to get lead from instagram? example if someone send me direct message or comment on my post and then they generate to lead
    • Where is the desktop app for Zoho Projects???

      As a project manager, I need a desktop app for the projects I manage. Yes, there's the web app, which is AWESOME for cross browser and platform compatibility... but I need a real desktop app for Projects that allow me to enter offline information where
    • White Label certificate

      Hi all, About 72 hours ago, we fulfilled all steps for white labeling (CNAME to point to mail.cs.zohohost.eu), but since then the configuration page is now stuck at "generating certificate" since 3 days. When I execute an NSLOOKUP mail.webfoundry.be it
    • How to Automate Monthly PDF Reports with Filters in Zoho Creator

      Hi everyone, I’m trying to build an automated monthly reporting process in Zoho Creator and would appreciate suggestions or best practices from anyone who has done something similar. What I’m trying to do: I have a form called New_Customer with fields
    • Feedback: Streamlining Note Management in Zoho Notebook

      Dear Team/Support, I would like to share some feedback regarding the note management system that could help improve usability and accessibility for users like myself. Notebook 1 (screenshot attached): Currently, the system does not allow selecting and
    • showing Limit exceeded

      Good afternoon...trust you're good. I've been having issues working with but it's not responding. it's showing Limit exceeded, sorry it seems like too many people are working on the sheet right now please try again later. meanwhile no one is working on
    • Sorting columns in Zoho Projects

      Hi, In project management best practice, sorting columns (ascending, descending) is an important tool. Sorting dates to see the order of tasks starting, sorting on priority or even on planned hours is a must for an efficient project control. Currently,
    • Upload API

      I'm trying to use the Upload API to upload some images and attach them to comments (https://desk.zoho.com/DeskAPIDocument#Uploads#Uploads_Uploadfile) - however I can only ever get a 401 or bad request back. I'm using an OAuth token with the Desk.tickets.ALL
    • Losing description after merging tickets

      Hello, We merge tickets when they are about the same topic from the same client. It happens sometimes. We recently noticed that after the merger only the description from the master ticket is left in a thread. And the slave-ticket description is erased.
    • update linked contacts when update happens in account

      Hi, I have a custom field called Licence in the Accounts module. When someone buys a licence, I’d like to update a custom field in the related Contacts. How can I achieve this? I noticed that workflows triggered on Accounts only allow me to update fields
    • Problem Management Module

      I am looking for a Problem Management module within Zoho Desk. I saw in some training videos that this is available, and some even provided an annual price for it. I want an official confirmation on whether this is indeed available. This is not a particularly
    • Unable to explore desk.zoho.com

      Greetings, I have an account with zoho which already has a survey subscription. I would like to explore desk.zoho.com, but when I visit it while logged in (https://desk.zoho.com/agent?action=CreatePortal) I just get a blank page. I have tried different
    • Offline support for mobile app

      Accessing your files and folders from your mobile devices is now quicker and simpler, thanks to the power of offline support. Whether on an Android or iOS device, you can use the Offline function to save files and folders, so you can review them even
    • Zoho Desk KB article embedded on another site.

      We embed KB articles from Zoho Desk on another site (our application). When opening the article in a new tab, there is no issue, but if we choose lightbox, we are getting an error "To protect your security, help.ourdomain.com will not allow Firefox to
    • OPTED FOR STORAGE BY DESCRIPTIVE MISGUIDANCE

      We've opened a domain with three mail ids and payment has also been processed now the bill raised is for single use ID with additional storage capacity. Kindly request you to modify the purchase.
    • List of packaged components and if they are upgradable

      Hello, In reference to the article Components and Packaging in Zoho Vertical Studio, can you provide an overview of what these are. Can you also please provide a list of of components that are considered Packaged and also whether they are Upgradable?
    • Does Attari Messaging app have Bot option and APIB

      Hi, Does Attari also have Bot and API as we use in WhatsApp??
    • How to add application logo

      I'm creating an application which i do not want it to show my organization logo so i have changed the setting but i cannot find where to upload/select the logo i wish to use for my application. I have seen something online about using Deluge and writing
    • Email login error

      Login successfully but email page error
    • Zoho Analytics Regex Support

      When can we expect full regex support in Zoho Analytics SQL such as REGEXP_REPLACE? Sometimes I need to clean the data and using regex functions is the easiest way to achieve this.
    • Change of Blog Author

      Hi, I am creating the blog post on behalf of my colleague. When I publish the post, it is showing my name as author of the post which is not intended and needs to be changed to my colleague's name. How can I change the name of the author in the blogs?? Thanks, Ramanan
    • Show Attachments in the customer portal

      Hi, is it possible to show the Attachments list in the portal for the particular module? Bests.
    • Feature Request - Insert URL Links in Folders

      I would love to see the ability to create simple URL links with titles in WorkDrive. or perhaps a WorkDrive extension to allow it. Example use case: A team is working on a project and there is project folder in WordDrive. The team uses LucidChart to create
    • How to sync from Zoho Projects into an existing Sprint in Zoho Sprints?

      Hi I have managed to integrate Zoho Projects with Zoho Sprints and I can see that the integration works as a project was created in Zoho Sprints. But, what I would like to do is to sync into an existing Zoho Sprints project. Is there a way to make that
    • how to differentiate if whatsapp comes from certain landing page?

      I create a Zobot in SalesIQ to create a Whatsapp bot to capture the lead. I have 2 landing pages, one is SEO optimized and the other want is optimized for leads comes from Google Ads. I want to know from which landing page this lead came through WhatsApp
    • Split my account

      Hello, I recently bought an email service for a friend. But, looks like I used my personal account to buy the plan. Please split the account so that the email service stays in a different account than my personal account.
    • Next Page