NetSuiteでカスタムSuiteletを構築する場合、Webベースのダッシュボード、分析レポート、ヘルプ・ドキュメント、別のシステムのインタフェースなど、外部コンテンツをフォームに直接埋め込む必要がある場合があります。これを行うための簡単で効果的な方法の1つは、INLINEHTMLフィールドを使用して<iframe>を挿入することです。
この方法では、外部リソースをシームレスに統合することでSuiteletの機能が強化され、ユーザーはNetSuite環境を離れることなく、役立つツールや情報にアクセスできます。
SuiteScript 2.0では、INLINEHTMLフィールド・タイプを使用して、RAW HTMLコードをSuiteletフォームに注入できます。<iframe>タグをフィールドのdefaultValueに割り当てることで、Suitelet内に外部コンテンツまたは内部コンテンツを表示できます。
/**
* @NApiVersion 2.x
* @NScriptType Suitelet
* @NModuleScope SameAccount
*/
define(['N/ui/serverWidget'],
function(widget) {
/**
* Definition of the Suitelet script trigger point.
*
* @param {Object} context
* @param {ServerRequest} context.request - Encapsulation of the incoming request
* @param {ServerResponse} context.response - Encapsulation of the Suitelet response
*/
function onRequest(context) {
if (context.request.method == 'GET'){
var form = widget.createForm({
title: 'SS2 Suitelet IFrame Demo'
})
var senderField = form.addField({
id: 'custpage_sender',
type: widget.FieldType.INLINEHTML,
label: 'Sender'
});
senderField.defaultValue = '<iframe> </iframe>';
form.addSubmitButton({
label : 'Submit Button'
});
context.response.writePage(form)