ディスカッション
NetSuiteの保存検索やレポートをマスターするための究極のガイドである分析センターを使用して、データの力を最大限に活用しましょう。複雑さを単純化し、組織の真の可能性を解き放ちます。今すぐ分析センターに参加して、新たな高みを目指しましょう!
New AI Community Guidelines. Please review and follow them to ensure AI use stays safe, accurate, and compliant.
Update: Narrative Insights has been restored and is now available.
Narrative Insights is Temporarily Unavailable due to an Infrastructure Issue. Learn how This Impacts Your Account and What to Expect While the Feature is Disabled.
Narrative Insights is Temporarily Unavailable due to an Infrastructure Issue. Learn how This Impacts Your Account and What to Expect While the Feature is Disabled.
SuiteScriptとカスタムフィールドを使用して注文書のアイテムの総重量を計算する
適用
製品: NetSuite 2023.1
シナリオ
ユーザーは注文書のアイテムの総重量を動的に計算したいと考えています。計算は、アイテムレコードに入力された重量値が同じ単位である場合にのみ機能します。
解決策
カスタムトランザクションラインフィールドの作成
- カスタマイゼーション> リスト、レコード、およびフィールド> トランザクションラインフィールド> 新規作成に移動します
- ラベル:単位重量を入力してください
- ID:_individual_weightを入力してください
- 種類:少数を選択
- 次に適用をクリックします
- 販売アイテム:チェックマークを入力してください
- 表示をクリックします
- 表示タイプ:無効を選択します
- ソーシングおよびフィルターをクリックします
- ソースリスト:アイテムを選択
- ソース:重量を選択
- 保存をクリックします
カスタムトランザクションボディーフィールドの作成
- カスタマイゼーション> リスト、レコード、およびフィールド> トランザクションボディーフィールド> 新規作成に移動します
- ラベル:総重量を入力してください
- ID:_items_total_weightを入力してください
- 値を保存:チェックマークを入力
- 種類:少数を選択
- 次に適用をクリックします
- 販売:チェックマークを入力
- 表示をクリックします
- サブタブ:メインを選択
- 表示タイプ:無効を選択します
- 保存をクリックします
- SuiteScriptを作成する
- 以下のコードを使用してください。
- 以下のコードを使用してください。
- SuiteScript 1.0
function calculateTotalWeight(type){var lines = nlapiGetLineItemCount('item');var totalWeight = 0 ;for(var i=1; i< lines+1 ; i++){var weight = nlapiGetLineItemValue('item', 'custcol_individual_weight', i);var quantity = nlapiGetLineItemValue('item', 'quantity', i);var weightTimesQuantity = weight * quantity;totalWeight = totalWeight + weightTimesQuantity ;}nlapiSetFieldValue('custbody_items_total_weight', totalWeight);}
- SuiteScript 2.0
/***@NApiVersion 2.x*@NScriptType ClientScript*/var lines = objRecord.getLineCount({sublistId: 'item'});var totalWeight = 0 ;for(var i=1; i< lines+1 ; i++){var weight = record.getSublistValue({sublistId: 'item',fieldId: 'custcol_individual_weight',line: i});var quantity = record.getSublistValue({sublistId: 'item',fieldId: 'quantity',line: i});var weightTimesQuantity = weight * quantity;totalWeight = totalWeight + weightTimesQuantity ;
タグ付けされた:
0