Customer のオンボーディング workflow を準備する際、成長中の流通企業の管理者は、saved searches、workflows、およびインテグレーションを構築する前に、どの Customer フィールドに使用可能なデータが格納されているかを確認する必要がありました。たとえば、Customer Status フィールドには内部 ID が格納されている一方、ユーザーには読みやすいステータス名が表示されていました。
Script サンプル
この scheduled script は、フィールド・タイプ、格納されている値、および該当する場合は表示テキストをすばやく確認し、管理者が自動化を正しく構成できるようにします。
/**
* @NApiVersion 2 .1
* @NScriptType ScheduledScript
*/
define(['N/record', 'N/log'], (record, log) => {
const execute = () => {
// Load a Customer record.
const customer = record.load({
type: record.Type.CUSTOMER,
id: 123 // Replace with a valid Customer internal ID
});
// Customer fields to inspect.
const fieldIds = [
'companyname',
'email',
'entitystatus',
'isperson'
];
fieldIds.forEach((fieldId) => {
// Get the Field object to identify its type.
const field = customer.getField({
fieldId: fieldId
});
// Get the field's stored value.
const value = customer.getValue({
fieldId: fieldId
});
// Use the field type when logging the field information.
log.debug({
title: 'Customer Field: ' + fieldId,
details: 'Type: '+ field.type + ' | Value: ' + value
});
// Example: Select fields have an internal ID as their value.
if (field.type === 'select') {
const text = customer.getText({
fieldId: fieldId
});
log.debug({
title: fieldId + 'Display Text',
details: text
});
}
// Example: Checkbox fields return true or false.
if (field.type === 'checkbox') {
log.debug({
title: fieldId + 'Checkbox Result',
details: value ? 'Checked' : 'Not checked'
});
}
});
};
return {
execute
};
});
免責事項: ここに記載されているサンプルコードは、法律で許可される最大限の範囲で、いかなる種類の保証もなく「現状のまま」提供されます。Oracle + NetSuite Inc. は、サンプルコードの開発プラットフォームへの実装や、独自のWebサーバー構成の使用において、開発者の個々の成功を保証または保証しません。
Oracle + NetSuite Inc. は、サンプルコードに関連するデータまたは情報の使用、使用結果、正確性、適時性、完全性に関して、いかなる保証も行わず、すべての保証(明示的または黙示的)を否認します。特に、商品性、特定の目的への適合性、コードに関連するサービスまたはソフトウェアに関する保証を否認します。
Oracle + NetSuite Inc. は、サンプルコードに関連する行動から生じるいかなる種類の直接的、間接的または結果的な損害や費用についても責任を負いません。
SuiteScriptのデプロイの詳細は、これらのNetSuiteの始め方記事を確認してください。
SuiteScriptを使用してレコードを自動化する方法について、別の方法をご存じですか。ここで自由に共有しましょう!
免責事項:
この記事は、AI支援による翻訳ツールを使用して翻訳され、言語品質のレビューを実施しています。AIは記事本文およびサポートガイダンスの作成には使用されていません。