トランザクションを処理する場合、管理者は多くの場合、レコード上のユーザーが使用できるカスタム・フォームを確認する必要があります。これは、注文書のロール権限、フォーム制限、トランザクション・フォーム設定または予期しないフォーム動作をトラブルシューティングする場合に特に役立ちます。
使用可能なフォームの選択肢を検査する実用的な方法の1つは、SuiteScriptのgetSelectOptions()メソッドを使用することです。この方法では、注文書のカスタムフォーム・フィールドなど、選択/ドロップダウン・フィールドで使用可能なオプションをチェックできます。
次のスクリプトは、定期スクリプトが注文書をロードする方法、カスタムフォーム・フィールドを検査する方法、様々な検索フィルターをテストする方法、およびドロップダウンから使用可能な注文書フォームをログに記録する方法を示します。
SuiteScriptの例
/**
* @NApiVersion 2.x
* @NScriptType ScheduledScript
*
*/
define(['N/record', 'N/log'], function(record, log) {
function execute(context) {
try {
/*
* Replace this with a valid Sales Order internal ID
* from your NetSuite account.
*/
var SALES_ORDER_ID = 00000;
/*
* The field we want to inspect.
*
* customform is the transaction form field.
* On a Sales Order, this represents the selected Sales Order form.
*/
var FIELD_ID_TO_CHECK = 'customform';
/*
* Filters to test against the customform dropdown.
*
* getSelectOptions() supports:
* - contains
* - startswith
* - is
*/
var filtersToTest = [
{
label: 'Forms containing "Standard"',
filter: 'Standard',
operator: 'contains'
},
{
label: 'Forms starting with "Sales"',
filter: 'Sales',
operator: 'startswith'