Sagar Hiray
10/07/2024, 1:00 PMCeligo AI
10/07/2024, 1:00 PMAI generated answer (using internal Slack threads):To add an HTML table in a Suitelet, you can use the
n/ui/serverWidget
module to create a form and add an Inline HTML field to it. This field can contain your HTML table. Here's a basic example:
javascript
var serverWidget = require('N/ui/serverWidget');
function onRequest(context) {
if (context.request.method === 'GET') {
var form = serverWidget.createForm({
title: 'My Form'
});
var htmlField = form.addField({
id: 'custpage_html',
type: serverWidget.FieldType.INLINEHTML,
label: 'HTML Field'
});
htmlField.defaultValue = '<table><tr><th>Header 1</th><th>Header 2</th></tr><tr><td>Data 1</td><td>Data 2</td></tr></table>';
context.response.writePage(form);
}
}
exports.onRequest = onRequest;
In this example, custpage_html
is an Inline HTML field that contains an HTML table. The defaultValue
property of the field is set to the HTML string of the table.
If you want to add client-side code like functions that should execute on click, you can include them in the HTML string. However, you need to be aware that Suitelet is server-side rendering, so you can't directly use SuiteScript modules in your client-side code. If you need to use SuiteScript modules, you can attach a Client Script to your form instance via its clientScriptModulePath
property, then all your client-side code goes there.
For example:
javascript
form.clientScriptModulePath = "./client-side-suitelet.js";
In this case, the client-side code should be in a file named client-side-suitelet.js
in the same folder as the Suitelet. You don't need to create a script record for this file.
******
Disclaimer:
This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes.
******Celigo AI
10/07/2024, 1:01 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.822086215
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.82071054
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.81987381
Celigo AI
10/07/2024, 1:01 PM