This article is relevant if you are seeking to use NetSuite and you are troubled by the way it limits information access by it’s use of the “(more…)” link.
Background
One of the great things about working with many clients is to learn about all kinds of different concerns and then coming up with solutions. I guess I like puzzles. For a client where we are assisting them to get off QuickBooks, they have a memorized invoice practice that requires them to modify line items every month. They need to quickly be able to see the information on an old invoice to refine it for this month’s invoice. They do not want to click into the description area unless there is indeed an actual change.
When a line has a long text (string) description, NetSuite has created an arbitrary limit (250 characters) to the amount of text shown until the user click’s More… They do not give users the ability to configure this limit option. Our client felt it was important to solve this. Note, they are moving to our custom NetSuite Recurring Billing Engine in a Phase II implementation where this concern will be less important.
Client Side SuiteScript Solution to More Challenge
The puzzle was solved by one of our senior consultants. He first solved it when the form was in View mode and it was relatively straight forward. But the client also wanted the “(more…)” link to also not be present when the form was in Edit mode. This requirement proved to be much more challenging because the environment is dynamic. And so we have the solution for you. Note, the following code segment breaks NetSuite’s Built for NetSuite guidelines because we are effectively in the Browser Document Object Model (DOM) manipulating HTML.
function clientShowFullLineItemDescriptions() { // this is a client side function that needs to be delivered to the form via // a beforeload user event script (not shown here) //change NetSuite's string limit from 250 characters to 5,000 by overriding their functions
try { if (typeof Machine != "undefined") eval("Machine.prototype.getDisplayCellContent=" + Machine.prototype.getDisplayCellContent.toString().replaceAll("250","5000")); } catch (e) { // do nothing } // this is the name of the table that NS uses in view mode on transaction line items var tbl = document.getElementById('item_splits'); // get all table rows from the items table var rows = tbl.getElementsByTagName("tr"); // find out in which column the Description appears // to do that, grab the header row and look for the column labeled "DESCRIPTION" // if you can't find that, then we're out of luck, so exit var descColNbr = -1; var headerCells = rows[0].getElementsByTagName("td"); for (var i = 0; i < headerCells.length; i++) { var str = headerCells[i].innerText; if (str.toUpperCase().substring(0,11) == "DESCRIPTION") { descColNbr = i; break; } } if (descColNbr < 0) { console.log("unable to find DESCRIPTION column in ITEMS table."); return; } // loop through all the rows and replace to handle html escaping for (var row = 1; row < rows.length; row++) { var td = rows[row].getElementsByTagName("td"); if (td.length >= descColNbr) { var desc = lineItemDescriptions[row]; if (desc) { var desc = desc.replace(new RegExp("<br>", 'g'), "\n").replace(new RegExp(""", 'g'), '"'); td[descColNbr].innerText = desc; } } } }
Make NetSuite Work the Way you Want
While NetSuite has done a great job providing a platform that can be customized and extended, sometimes you have to go beyond the prescribed practices to get the job done. You too can have it your way, if you are willing to try. If you are working with NetSuite and you are ready to solve concerns to improve your overall experience, let’s have a discussion.
Hi Martin,
I would like to use this script, but it throws an error about “lineItemDescriptions” not being defined.
Could you give me some help?
Thanks in advance