以下は、ハンドルバーを使用するスイートレットのサンプルです。フォームオブジェクトを作成し、レンダリングされたハンドルバーテンプレートを保持するhtmlフィールドを作成することによって、スイートレットを設定します。
var screenTitle = 'Form Title';
var form = nlapiCreateForm(screenTitle);
var pageTemplate = nlapiLoadFile('SuiteBundles/Bundle '+sitBundleId+'/src/sit_html_templates/template.html').getValue();
var hbTemplate = Handlebars.compile(pageTemplate);
Handlebars.registerHelper('if_eq',function(a,b,opts) { if(a == b) { return opts.fn(this); } else { return opts.inverse(this); } });
Handlebars.registerHelper('json', function(context) { return JSON.stringify(context); });
var data = {
"account_id":nlapiGetContext().getCompany(),
"bundle_id":sitBundleId,
"other_data":{}
};
var htmlValue = hbTemplate(data);
var templateField = form.addField('template_section','inlinehtml','',null,'main_group');
templateField.setDefaultValue(htmlValue);
response.writePage(form);
これは基本的なことです。もちろん、HandlebarライブラリをNetSuite Suiteletレコードのライブラリサブリストに追加する必要があります。
これは素晴らしく洗練されたソリューションです。素敵で簡単なことです。ありがとうalot – user125264
私はソリューションが助けてうれしいです... – scheppsr77