Search code examples
javascriptnetsuitesuitescriptscriptletsuitescript2.0

Netsuite SuiteScript how to get value from the redirected url


In Netsuite, i am generating a button using Suitelet Script Type. when i click it , it will take me from current Netsuite page to a 3rd party page .When i am in 3rd party page and click submit in 3rd party page , it will redirect me back to Netsuite page which will have new URL like below. How to capture the URL values in the Suitelet i created.

URL : https://system.netsuite.com/pages/customerlogin.jsp?code=U50YFx&state=xyz

I want to capture this url and get the value of "code" above. Can some one please tell how to achieve that .


Solution

  • Im able resolve this by calling client script from the Suitelet . The redirect url will take me to the suitelet. And in client script i added below code :

    var currentUrl=document.location.href;
        var url = new URL(currentUrl);
        var authCode = url.searchParams.get("code");