[英]Netsuite: Analyzing Line before adding to Sales Order
我正在嘗試通過 SuiteScript 創建一個彈出窗口,在將商品添加到訂單中時,我們將顯示可用庫存和客戶首選品牌以及其他一些詳細信息,以便 Cust Svc 代表能夠添加正確的 sku 並詢問客戶在將商品添加到訂單之前需要回答的問題。 為此,我需要能夠在添加之前訪問該項目。 我現在設置的彈出窗口確實會顯示 - 但我需要我嘗試添加的數量和 SKU。 當前代碼:
/**
*@NApiVersion 2.x
*@NModuleScope Public
*@NScriptType ClientScript
*/
define(['N/search'], runClientscript);
function runClientscript(search){
SEARCHMODULE = search;
function validateLine(context) {
var currentSO = context.currentRecord;
context.sublistId;
if(context.sublistId == 'item'){
alert("validateLine Triggered!");
var cr = context.currentRecord;
var quantityLine = currentSO.getSublistValue({
sublistId : 'item',
fieldId : 'quantity',
line : 1
});
}
return true; //Return true if the line insertion is valid.
}
/**
*
* @param {object} context context object from user event.
*/
function getLocationContext(context){
var contextObj = {};
contextObj.locationRecord = "customrecord_ship_priority";
contextObj.warehouseIds = [
{
name:"custrecord_nj_warehouse",
value:3
},
{
name:"one",
value:9
},
{
name:"two",
value:8
},
{
name:"three",
value:4
}
]
contextObj.parameters = getScriptParameter();
return contextObj;
}
var returnObj = {};
returnObj.validateLine = validateLine;
return returnObj;
}
任何幫助,將不勝感激。 謝謝!!
使用currentSo.getCurrentSublistValue({type: 'item', fieldId: '{fieldyouneedtodisplay}'})
代替,它將給出正在添加到 validateline 的項目的信息。 獲得所需的所有信息后,您就可以像下面的偽代碼一樣進行驗證。
var sItem = currentSo.getCurrentSublistText({type: 'item', fieldId: 'item'});
var nQqty = currentSo.getCurrentSublistValue({type: 'item', fieldId: 'quantity'});
//your code to validate goes after.
if(nQqty >=0){
alert('Adding ' + nQqty + ' of ' + sItem + '.')
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.