we have a suitelet that displays data we add this...
# suitescript
s
we have a suitelet that displays data we add this to handle no records showing up but the button to refresh doesnt work it just goes to this page https://xxxxxx.app.netsuite.com/app/site/hosting/scriptlet.nl
Copy code
function recordsTableGenerate(records, tableID, excludeRowNumber) {
    if (records === null || records.length === 0 ) {
      return `<body style="text-align: center;">
        <span style="font-size: 20px; color: red;">There are no records to display,</span>
        <span style="font-size: 20px; color: red;"> Try refreshing the page</span>
        <br></br>
        <button onclick="refreshPage()">Refresh Page</button>
         <script>
        // JavaScript function to refresh the page
        function refreshPage() {
             window.open("<https://xxxx.app.netsuite.com/app/center/card.nl?sc=-29&whence=>", "_self")
        }
    </script>
      </body>`;
    }
    // l
a
1. F5 already refreshes the page 😛 2. why would refreshing help, is there an assumption that new records will be loaded? is that assumption fair? 3. why refresh the page? why not just recall the suitelet with the params from the url?
I'm assuming you changed the url, and it doesn't really go to the NS homepage? but rather your suitelet results page?
is this suitelet available without login? if so I can see it getting weird if you try to refresh via an external suitelet with no session to the NS home page
finally I'd check in the browser what actually got attached to that button using browser dev tools, what you have in your code base might not be what actually renders
why do you need to pass a url to refresh? it should be the same url, no? so
window.location.reload()
should be all you need?
s
really I want it to go to the home page of NetSuite whether i set the location vs loction.href or window.open both go to this URL https://xxxxxx.app.netsuite.com/app/site/hosting/scriptlet.nl
a
ok so I'm guessing this is NOT available without login? and the user will have an active NetSuite session that they are authenticated into?
did you confirm with browser dev tools that the button has your refreshPage function happening on click? and that refreshPage function is loaded into the browser correctly?
e
I'm with Anthony in that for refreshing the page, I'd expect
window.location.reload()
to do the trick. For redirecting to the home page, you can use url.resolveTaskLink to dynamically determine the relative URL of the home page (e.g. so you don't have to care about computing the account ID for sandox/production). The card
id
of the home page is
CARD_-29
. You can then use the resulting relative URL as the input for window.location.assign.
s
<script> // JavaScript function to refresh the page function refreshPage() { window.location.assign("https://xxxxx.app.netsuite.com/app/center/card.nl?sc=-29&amp;whence=",) } </script>
e
Strange. Have you tried a relative URL instead? Using Tim's query tool as a test suitelet, I am able to redirect to the homepage using
window.location.assign('/app/center/card.nl?sc=-29')
from the client side
s
a
but if you do it in the console it just works as expected right? so my question remains, have you confirmed you code is loading in the browser correctly/
s
in the console it work correct
a
ok so then is NS somehow overwriting your code so it isn't actually executing what you think its executing?
s
i suspect that is the issue
a
cos if it works in the console, then that's the exact same thing as the client context