ユーザーが送信する前に、「修理」というアイテムが含まれる新しい販売注文を確認し、「修理コスト」という2番目のアイテムを追加する背後にあるコードを理解しようとしています。私は少し迷っています、そして私は与えられることができるどんな助けでも歓迎します。このスクリプトをJavascriptで作成し、Netsuiteの販売注文フォームに添付して実行します。
10687 次
2 に答える
3
これが1つのサンプルソリューションです:
アイテムの内部IDはRepair=100およびRepairCost=200であると引き続き想定します。
function recalc(type)
{
if(type == 'item')
{
var itemId = nlapiGetCurrentLineItemValue('item', 'item'); //Get the Item ID
if(itemId == 100) //Repair Cost
{
//Insert item
nlapiSelectNewLineItem('item');
nlapiSetCurrentLineItemValue('item', 'item', 200); //Repair Cost
nlapiSetCurrentLineItemValue('item', 'quantity', 1);
nlapiSetCurrentLineItemValue('item', 'amount', '0.00');
nlapiCommitLineItem('item');
}
}
return true;
}
これをクライアント側のコードとしてデプロイし、関数がRecalcであることを確認します。
クライアント側スクリプトの詳細については、https ://system.na1.netsuite.com/help/helpcenter/en_US/Output/Help/SuiteFlex/SuiteScript/SSScriptTypes_ClientScripts.html#1016773をご覧ください。
于 2013-03-12T19:01:06.420 に答える
1
最初に行う必要があるのは、アイテム「修理」と「修理費用」の内部IDを取得することです。
この例では、Repair=100およびRepairCost=200の内部IDを想定します。
コードは次のとおりです。
function afterSubmit(type)
{
if(type == 'create' || type == 'edit')
{
var record = nlapiLoadRecord(nlapiGetRecordType(), nlapiGetRecordId()); //Load the record
//Loop to all sublist item
var count = record.getLineItemCount('item');
for(var i = 1; i <= count; i++)
{
var item = record.getLineItemValue('item', 'item', i); //This will return the internal id of the item
if(item == 100) //Item is equal to 100; insert one item
{
record.insertLineItem('item', i);
record.setLineItemValue('item', 'item', i, 200); //Repair Cost internal id
record.setLineItemValue('item', 'quantity', i, 1); //You should put some quantity; depending on your account setup all required fields should be set here.
}
}
//Submit the changes
nlapiSubmitRecord(record, true);
}
}
suitescript APIと、このNetsuiteヘルプガイドの販売注文チェックに公開されるフィールドを理解するには、次のようにします。
https://system.netsuite.com/help/helpcenter/en_US/RecordsBrowser/2012_2/Records/salesorder.html
于 2013-03-11T21:33:04.220 に答える