Adam Weaver
03/27/2025, 1:56 PMCeligo AI
03/27/2025, 1:56 PMAI generated answer (using internal Slack threads):Based on the conversations, it seems like the issue is with the timing of the execution of the
highlightComponentRows
function. The function is set to execute after a delay of 1500ms (1.5 seconds) to allow the sublist to render fully. However, if the sublist takes longer than this to render, the function will execute before the sublist is fully loaded, and it won't be able to find the rows to highlight.
One potential solution could be to increase the delay time. However, this might not be a reliable solution as the rendering time can vary. A better approach might be to use an event that triggers after the sublist is fully loaded. Unfortunately, NetSuite does not provide such an event out of the box.
Here's a modified version of your script that uses a setInterval to periodically check if the sublist is loaded, and once it is, it calls the highlightComponentRows
function and clears the interval:
javascript
/**
* @NApiVersion 2.1
* @NScriptType ClientScript
*/
define(['N/currentRecord'], function(currentRecord) {
/**
* pageInit event: runs when the record page is initialized.
*/
function pageInit(context) {
log.debug("pageInit triggered.");
// Start checking if the sublist is loaded every 500ms.
var checkSublistLoaded = setInterval(function() {
var rec = currentRecord.get();
var lineCount = rec.getLineCount({ sublistId: 'component' });
// If the sublist is loaded (i.e., it has at least one line), highlight the rows and stop checking.
if (lineCount > 0) {
highlightComponentRows();
clearInterval(checkSublistLoaded);
}
}, 500);
}
// ... rest of your code ...
return {
pageInit: pageInit
};
});
This approach should ensure that the highlightComponentRows
function is called as soon as the sublist is loaded, regardless of how long it takes to load.
******
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
03/27/2025, 1:57 PMSlack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.848714
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.841803491
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.841772079
Celigo AI
03/27/2025, 1:57 PM