ディスカッション
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でデータを一括更新する方法(1.0 & 2.0対応)
📝 記事概要
NetSuiteでは、データを一括更新する手段として CSVインポート や ワークフロー がありますが、動的な更新が必要な場合は SuiteScript が最適です。本記事では、SuiteScript 1.0 & 2.0 で一括更新する方法を解説します。
🚀 SuiteScriptでの一括更新のポイント
✔ 特定条件のデータを柔軟に更新
✔ スケジュール実行で自動化可能
✔ 大量データ処理ならMap/Reduceを活用
📌 SuiteScript 1.0 でのスケジュールスクリプト
function scheduled_UpdateInvoices(type) {
// 「請求書(invoice)」レコードを検索(ステータスが「Open」のもの)
var results = nlapiSearchRecord('invoice', null,
[new nlobjSearchFilter('status', null, 'anyof', 'Open')],
[new nlobjSearchColumn('internalid')]
);
// 検索結果が存在する場合
if (results) {
for (var i = 0; i < results.length; i++) {
// 検索結果の 内部IDを取得し、ステータスを「全額適用済」に更新
nlapiSubmitField('invoice', results[i].getId(), 'status', 'PaidInFull');
}
}
}
✅ ポイント
nlapiSearchRecord()でデータ取得(条件:請求書のステータスが「Open」)nlapiSubmitField()でステータスを「PaidInFull」に一括更新- 最大1000件までのレコード を処理可能(1回の検索で取得できる最大件数)
📌 SuiteScript 2.0 でのスケジュールスクリプト
define(['N/record', 'N/search'], function(record, search) {
function execute(context) {
// 「請求書(invoice)」レコードを検索(ステータスが「Open」のもの)
var invoiceSearch = search.create({
type: search.Type.INVOICE, // レコードタイプを「INVOICE」に指定
filters: [['status', 'anyof', 'Open']], // フィルター条件(ステータスが「Open」)
columns: ['internalid'] // 取得するフィールド(internalid)
}).run().getRange({ start: 0, end: 1000 }); // 取得範囲(最大1000件)
// 検索結果を1件ずつ処理
invoiceSearch.forEach(function(result) {
// 内部IDを取得し、ステータスを「全額適用済」に更新
record.submitFields({
type: record.Type.INVOICE, // 更新対象レコード(請求書)
id: result.getValue('internalid'), // レコードID
タグ付けされた:
0