ディスカッション
NetSuiteの保存検索やレポートをマスターするための究極のガイドである分析センターを使用して、データの力を最大限に活用しましょう。複雑さを単純化し、組織の真の可能性を解き放ちます。今すぐ分析センターに参加して、新たな高みを目指しましょう!
New AI Community Guidelines. Please review and follow them to ensure AI use stays safe, accurate, and compliant.
Keep an eye out for upcoming NetSuite events, including meetups, workshops, and webinars. These sessions are a great way to connect with peers, learn from experts, and stay current on the latest NetSuite updates and best practices. Registration links are provided in each event.
NetSuite の始め方 |クライアント・スクリプト: fieldChanged(scriptContext)
NetSuite の始め方 | SuiteScript タイプの概要 の記事のすべてのタイプのSuiteScriptについて説明したところで、様々なタイプのクライアント・スクリプトに焦点を当てます。最初はfieldChanged(scriptContext)です。
NetSuiteのfieldChangedイベントは、フィールドの値がUIで変更されるたびにトリガーされます。このイベントは、ユーザーがフィールド値を変更した直後に、検証、計算またはその他のアクションを実行する場合に特に役立ちます。fieldChangedイベント・ハンドラ・ファンクションは、変更されたフィールドおよび現在のレコードに関する情報を含むscriptContextオブジェクトを受信します。
fieldChangedスクリプトの基本構造
fieldChangedスクリプトの基本的な例を次に示します。
/**
* @NApiVersion 2.x
* @NScriptType ClientScript
* @NModuleScope SameAccount
*/
define(['N/error','N/currentRecord'],
function(error,currentRecord) {
/**
* フィールドの変更時に実行される関数
*
* @param {Object} scriptContext
* @param {Record} scriptContext.currentRecord – 現在のフォームレコード
* @param {string} scriptContext.sublistId - サブリスト名
* @param {string} scriptContext.fieldId – フィールド名
* @param {number} scriptContext.lineNum - 明細名. サブリストまたはマトリクス・フィールドではない場合、未定義になります
* @param {number} scriptContext.columnNum - 明細番号。マトリックス フィールドでない場合は未定義
*
* @since 2015.2
*/
function fieldChanged(scriptContext) {
var currentRecord = scriptContext.currentRecord;
var fieldId = scriptContext.fieldId;
// 例: 「quantity(数量)」フィールドが変更されたときに処理を実行します。
if (fieldId === 'quantity') {
var quantity = currentRecord.getValue({ fieldId: 'quantity' });
// Perform some logic, such as validation or calculations
if (quantity < 0) {
currentRecord.setValue({
fieldId: 'quantity',
value: 0
});
alert('Quantity cannot be negative. Resetting to 0.');
}
}
}
return {
fieldChanged:fieldChanged
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!
タグ付けされた:
0
