ディスカッション
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 2022.1
シナリオ
全ての仕入先レコードの仕入先と子会社の関係を設定したい。
解決策
SuiteScript 1.0:
//Create a search that will get all vendor records
var vendorSearch = nlapiSearchRecord("vendor", null, [], [new nlobjSearchColumn("internalid")]);
// for loop that will loop until the last value of the Object
for(var i = 0 ; i< vendorSearch.length ; i++){
var Id = vendorSearch[i].getValue('internalid') // get the internal Id of the Vendor
var vsr = nlapiCreateRecord('vendorsubsidiaryrelationship');
vsr.setFieldValue('entity', id);
vsr.setFieldValue('subsidiary', 3); //internal ID of a subsidiary you want to relate this vendor to
var recId = nlapiSubmitRecord(vsr);
nlapiLogExecution('DEBUG', 'vsr Record ID', recId)
}
SuiteScript 2.0:
var vendorSearch = search.create({
type: search.Type.VENDOR,
title: 'Vendor search',
columns: ['internalid']
});
var resultSet = vendorSearch.run();
var resultRange = resultSet.getRange({
start: 0,
end: 100
});
var loopCount = 1;
for(var i = 0; i < resultRange.length; i++){
var id = resultRange[i].getValue('internalid');
if(id > 0){
var vsr = record.create({
type: record.Type.VENDOR_SUBSIDIARY_RELATIONSHIP
});
vsr.setValue({
fieldId: 'entity',
value: id
});
vsr.setValue({
fieldId: 'subsidiary',
value: 2
});
var recId = vsr.save();
log.debug(recId);
loopCount += 1;
}
}
タグ付けされた:
0