This article is relevant if you are developing SuiteLets using SuiteScript 2.0 and you need LONGTEXT or RICHTEXT sublist field types.
Background
In our NetSuite Systems Integration Practice, we developed a custom ticket manager application (we call it Prolecto Task Manager or PTM) that sits on top of NetSuite Case structures but presents a refined user experience. One reason we did this is that we work with contractors who use the NetSuite Vendor Center and thus do not have direct access to the NetSuite Case system. Thus, our SuiteLet approach allows us to have contractors act like internal employees. Furthermore, the SuiteLet approach also allows us to let our customers gain controlled access to the underlying case information with or without login.
We wanted to show, in a list fashion, the HTML Case message history. However, when we were programming SuiteScript 2.0, we realized that LongText and RichText data types are not supported as we received this error message during development:
SSS_INVALID_TYPE_ARG”,”message”:” You have entered an invalid type argument: LONGTEXT/RICHTEXT
NetSuite SuiteScript 2.0 Support
We reported to NetSuite our concern and it is summarized below:
Issue Number: 520145
Abstract: SuiteScript 2.0 > Suitelet > Sublist.addField(options) > SSS_INVALID_TYPE_ARG”,”message”:” You have entered an invalid type argument: LONGTEXT/RICHTEXT.
Details: Alternate Solution: Use TEXTAREA instead of RICHTEXT or LONGTEXT.
Severity: S3 – Issue
Current Status: Open – Under Investigation
Case: 3235621: Defect 520145: SuiteScript > Add Sublist Field of Type LONGTEXT/RICHTEXT
Status Change:
Status changed from Open – Pending Investigation to Open – Under Investigation
Workaround for the SuiteScript LongText / Richtext Sublist Challenge
We developed a workaround to this limitation. We produced our own read-only sublist by using an HTML formatted table coupled to NetSuite’s style elements and outputted the table in a single HTML INTLINEHTML field. While not perfect, the pattern is at least a workaround that you can use as inspiration in your NetSuite application. Here is the SuiteScript 2.0 code pattern:
// SuiteScript 2.9 code written by Marty Zigman // modifed to help NetSuite community //add a tab to the form for the HTML Message List var msgTab = form.addTab({ id: 'msg_html_list_tab', label: 'Messages' }); //add a field group to set it apart form.addFieldGroup({ id: 'msg_html_fg', label: 'Messages', tab: 'msg_html_list_tab' }); // create a single field to hold all of HTML that will be presented as a list var msgHtmlField = form.addField({ id: 'msg_html_list', type: ui.FieldType.INLINEHTML, label: 'HTML Table', container: 'msg_html_list_tab' }).updateDisplayType({ displayType: ui.FieldDisplayType.INLINE }); //caseid is a variable set earlier if (caseid){ var myFilters = []; var myColumns = []; myFilters.push(search.createFilter({name: 'internalid',join: 'case', operator: search.Operator.ANYOF, values: caseid})); myColumns.push(search.createColumn({name: 'internalid',sort: search.Sort.DESC})); myColumns.push(search.createColumn({name: 'messagedate'})); myColumns.push(search.createColumn({name: 'author'})); myColumns.push(search.createColumn({name: 'message'})); var messageSearch = search.create({ type: 'message', filters: myFilters, columns: myColumns }); var searchResult = messageSearch.run().getRange({start:0,end:19}) //limit result to last 20 messages //build the HTML table header var msgHTML = '<table width=100%" class="listtable listborder uir-list-table" style="position: relative;" ><tr class="uir-machine-headerrow">'; msgHTML += '<td class="listheadertdleft listheadertextb uir-column-large">Date & Author</td>' msgHTML += '<td class="listheadertdleft listheadertextb uir-column-large">Message</td>' //spin through results and draw html table row/cell elements for (var i = 0; i < searchResult.length; i++){ var msgRow = (i % 2) ? 'even' : 'odd'; msgHTML += '</tr><tr class="uir-list-row-tr uir-list-row-' + msgRow + '">'; msgHTML += '<td class="uir-list-row-cell listtext">' + searchResult[i].getValue({name: 'messagedate'}) + ' by ' + searchResult[i].getText({name: 'author'}) + '</td>'; var msg = searchResult[i].getValue({name: "message"})||""; msgHTML += '<td class="uir-list-row-cell listtext">' + msg + '</td>'; } msgHTML += '</tr></table>' //output the HTML into the INLINEHTML field msgHtmlField.defaultValue = msgHTML; }
NetSuite User Interface is Fundamentally HTML
When we are developing NetSuite custom applications, it’s sometimes important to remember that the NetSuite platform user experience is an HTML based client interface. Yes, the NetSuite API does a fabulous job abstracting away much of the HTML complexity. But when we run into challenges, we should always be prepared to “take matters into our own hands” even if the NetSuite guidelines suggest that we should not. Ultimately, the idea is to take full responsibility to produce the experience we want for our users. In this simple case, the risk is especially low because the information is read-only.
If you found this article helpful, feel free to subscribe to get notifications of new articles. If you have a SuiteScript 1.0 / 2.0 situation that you want to take care, let’s have a conversation.