ディスカッション
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.
アイテム単価とカスタムラインフィールドの値に基づいてアイテムの金額を計算するサンプルスクリプト
適用
製品: NetSuite 2021.2
シナリオ
注文書のアイテム金額の標準計算を上書きし、カスタムトランザクションラインフィールドとアイテム単価の値に基づいて再計算します。
解決策
サンプルスクリプトは以下となります。このサンプルは、beforeSubmit関数のユーザーイベントスクリプトデプロイをしてください。
SuiteScript 1.0:
function beforeSubmit(){
var currentContext = nlapiGetContext();
var executionContext = currentContext.getExecutionContext();
nlapiLogExecution('DEBUG','executionContext ',executionContext );
var lineItemCount = nlapiGetLineItemCount('item');
for(var i = 1; i<=lineItemCount; i++) {
nlapiSelectLineItem('item',i);
var qty_1 = nlapiGetCurrentLineItemValue('item','custcol_1');
var qty_2 = nlapiGetCurrentLineItemValue('item','custcol_2');
var itemrate = nlapiGetCurrentLineItemValue('item','rate');
var amount = qty_1 * qty_2 *itemrate;
nlapiSetCurrentLineItemValue('item','amount',amount );
nlapiCommitLineItem('item');
}
}</code>
SuiteScript 2.0:
var executionContext = runtime.executionContext()
log.debug('DEBUG', 'executionContext', executionContext)
//Load the record using record.load
var lineItemCount = objRecord.getLineCount({
sublistId: 'item'
});
for(var i = 1; i<=lineItemCount; i++) {
var lineNum = objRecord.selectLine({
sublistId: 'item',
line: i
});
var qty_1 = objRecord.getCurrentSublistValue({
sublistId: 'item',
fieldId: 'custcol_1'
});
var qty_2 = objRecord.getCurrentSublistValue({
タグ付けされた:
0