1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

【実験】SuiteScriptの自動生成 ーその1ー

Posted at

✅ 成功例①「自分のユーザー情報をJSONで出力」

概要

NetSuiteログインユーザー自身の基本情報(ユーザーID、名前、メールアドレス、部署など)を取得し、JSON形式で出力するスクリプト。

実行したプロンプト

#SuiteScript生成
#NetSuite
#自分のIDに関する情報の出力

生成されたスクリプト

/**
 * @NApiVersion 2.1
 * @NScriptType Suitelet
 */
define(['N/search'], (search) => {

    const onRequest = (context) => {
        if (context.request.method === 'GET') {

            const quotaSearch = search.load({
                id: 'customsearch_sales_quota_currentyear' // 保存済み検索のIDに置き換え
            });

            const results = [];
            quotaSearch.run().each(result => {
                results.push({
                    id: result.id,
                    salesrep: result.getText({ name: 'salesrep' }),
                    quota: result.getValue({ name: 'quota' }),
                    quotaname: result.getValue({ name: 'quotaname' }),
                    targetontotal: result.getValue({ name: 'targetontotal' })
                });
                return true;
            });

            context.response.setHeader({ name: 'Content-Type', value: 'application/json' });
            context.response.write({ output: JSON.stringify(results, null, 2) });
        }
    };

    return { onRequest };
});
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?