When building custom Suitelet in NetSuite, there may be a need to embed external content directly within the form—such as a web-based dashboard, analytics report, help documentation, or another system’s interface. One simple and effective way to do this is by using an INLINEHTML field to insert an <iframe>.
This method enhances the Suitelet's functionality by integrating external resources seamlessly, giving users access to helpful tools and information without leaving the NetSuite environment.
In SuiteScript 2.0, the INLINEHTML field type allows you to inject raw HTML code into a Suitelet form. By assigning an <iframe> tag to the field's defaultValue, you can display external or internal content within the 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)
}
}
return {
onRequest: onRequest
};
});
define(['N/ui/serverWidget'], function(widget) {
- Uses
define to load the N/ui/serverWidget module, which is used to build NetSuite UI forms.
function onRequest(context) {
- onRequest is the function triggered when the Suitelet is accessed via a URL.
- The context object contains both the request and response objects.
if (context.request.method === 'GET') {
- Ensures the code inside runs only when the Suitelet is first loaded (not on form submission).
var form = widget.createForm({
title: 'SS2 Suitelet IFrame Demo'
});
- Initializes a form with the title “SS2 Suitelet IFrame Demo” that will be rendered in the NetSuite UI.
var iframeField = form.addField({
id: 'custpage_iframe',
type: widget.FieldType.INLINEHTML,
label: 'Iframe Viewer'
});
- Adds a field of type INLINEHTML, which allows embedding custom HTML.
- The field ID is custpage_sender, and the label shown on the form is “Sender”.
senderField.defaultValue = '<iframe> </iframe>';
- Assigns a blank
<iframe> tag as the default value of the field.
form.addSubmitButton({
label : 'Submit Button'
});
- Adds a generic "Submit Button" to the form.
context.response.writePage(form);
- Outputs the fully constructed form as the Suitelet response.
return {
onRequest: onRequest
};
- Exposes the
onRequest function so NetSuite knows what to run when the Suitelet is accessed.
The sample code described herein is provided on an "as is" basis, without warranty of any kind, to the fullest extent permitted by law. Oracle + NetSuite Inc. does not warrant or guarantee the individual success developers may have in implementing the sample code on their development platforms or in using their own Web server configurations.
Oracle + NetSuite Inc. does not warrant, guarantee or make any representations regarding the use, results of use, accuracy, timeliness or completeness of any data or information relating to the sample code. Oracle + NetSuite Inc. disclaims all warranties, express or implied, and in particular, disclaims all warranties of merchantability, fitness for a particular purpose, and warranties related to the code, or any service or software related thereto.
Oracle + NetSuite Inc. shall not be liable for any direct, indirect, or consequential damages or costs of any type arising out of any action taken by you or others related to the sample code.
How are you using IFrame in Suitelet in your business? Share them in the NetSuite Admin Corner