ディスカッション
NetSuiteの保存検索やレポートをマスターするための究極のガイドである分析センターを使用して、データの力を最大限に活用しましょう。複雑さを単純化し、組織の真の可能性を解き放ちます。今すぐ分析センターに参加して、新たな高みを目指しましょう!
NetSuite の始め方 |クライアント・スクリプト: validateField(scriptContext)
「 NetSuiteの始め方 | SuiteScript の種類の概要」の記事にあるすべてのタイプのSuiteScriptについて説明した後、様々なタイプのクライアント・スクリプトに焦点を当てます。ユーザーがフィールドを変更し、フィールドから移動しようとすると、validateFieldがトリガーされます。
- フィールド長の検証: テキスト・フィールドが特定の文字数を超えないようにしてください。
- エントリを事前定義書式に制限:電話番号、Eメール・アドレス、IDなどのパターンを適用します。
- 指定された範囲への値の制限:数値フィールド(割引率など)が有効な範囲内にとどまるようにします。
- 相互検証フィールド:送信を許可する前に、フィールド値を別のフィールドと比較します。
ノート: これはボディ・フィールドにのみ適用されます。
validateField関数の簡単な例を次に示します。
/**
* @NApiVersion 2.x
* @NScriptType ClientScript
* @NModuleScope SameAccount
*/
define(['N/error','N/currentRecord'],
function(error,currentRecord) {
/**
* Validation function to be executed when sublist line is committed.
*
* @param {Object} scriptContext
* @param {Record} scriptContext.currentRecord - Current form record
* @param {string} scriptContext.sublistId - Sublist name
*
* @returns {boolean} Return true if sublist line is valid
*
* @since 2015.2
*/
function validateField(scriptContext) {
var currentRecord = scriptContext.currentRecord;
var fieldId = scriptContext.fieldId;
var sublistId = scriptContext.sublistId;
if (fieldId === 'memo') {
var fieldValue = currentRecord.getValue({ fieldId: fieldId });
if (!fieldValue) {
var currentDesc = currentRecord.setValue({
fieldId: 'otherrefnum', //PO # field
value: 'Memo field cannot be empty.' Richard James Uri - SuiteCloud | WMS Tech | SuiteCommerce Advanced
----
- NetSuite Admin Corner | New to NetSuite
- Explore the NSC Webinars Category
- Join our poll and share your ideas! We want to know what you think. Don't forget to comment and make your voice heard!
- Expand your NetSuite knowledge by joining this month's Ask A Guru Live about Suitecloud. RSVP on this event now!
タグ付けされた:
0
