Get Authorized NetSuite URL

I need to access a customer order in Netsuite from the SFDC login. I already have a code that gets the customer order number. My problem is that I need to create a URL to redirect to a customer order in NetSuite from sales. This requires getting the url ' https://system.na1.netsuite.com ' through the list of numbers. The "na1" in url stands for Noth America, and this is a change in url depending on the country. Hence by passing the email id, password to the actual login address https://system.netsuite.com/pages/customerlogin.jsp 'I need to get the authorized url. nlapiResolveURL(type, identifier, id, displayMode)

Creates a URL on the fly for the subsequent portion of the URL.

any idea or solution please?

+3


source to share


3 answers


Expanding on the answer posted by @ egrubaugh360 to get the base domain, here's an example.

function credentials(){
        this.email = "netsuiteEmail@example.com";
        this.account = "1234567";
        this.role = "25";
        this.password = "secretPassword";
    }

    //Setting up URL              
    var url = "https://rest.netsuite.com/rest/roles";

    //Calling credential function
    var cred = new credentials();

    //Setting up Headers 
    var headers = {"User-Agent-x": "SuiteScript-Call",
                   "Authorization": "NLAuth nlauth_account=" + cred.account + ", nlauth_email=" + cred.email + 
                                    ", nlauth_signature= " + cred.password + ", nlauth_role=" + cred.role,
                   "Content-Type": "application/json"};

    var response = nlapiRequestURL(url, null, headers);
    var results = JSON.parse(response.body);
    var domain = results[0].dataCenterURLs.systemDomain;

      



In addition, instead of systemDomain

, restDomain

and is webservicesDomain

also available. This is an example of calling a RESTlet from NetSuite, but you can do it in any language.

+3


source


If you've already retrieved the ID from the RESTlet, just add the URL to the returned object from the RESTlet. You should be able to generate the url using nlapiResolveURL

as you pointed out. It should look something like this:

var url = nlapiResolveURL('RECORD', 'salesorder', 1234);

      

where 1234

is the actual ID of the sales order. This will set url

to something like



/app/accounting/transactions/salesorder.nl?id=1234

      

To get the base domain, you will need to use the NetSuite Role Service in addition to using the RESTlet. You can see the NetSuite Help document titled "Using the REST Role Service to Get User Accounts, Roles, and Domains." It's really just a RESTlet provided by NetSuite that allows you to enter a username and password and return you all the accounts and roles that this user has access to. The result includes the correct REST domain for this account using the property restDomain

.

Also, for clarification, na1

the URL does not necessarily change from country to country, but more specifically based on the datacenter that hosts that account.

+2


source


What I would normally do for something like this would be to create a Suitelet or RESTLet to return all the order information. The RESTLet can return order details in JSON format and you can use them to format the order with your own view.

You can create a Suitelet that is accessed through a public URL, where part of the URL query string is an internal order ID (or order number) and a restricted token.

You can easily use Netsuite script templates to display a formatted sales order. If you need to edit an order, things get a little more complicated for some reason. Minor edits can be done more efficiently (like approve / reject and reason code) with Suitelet, but if you want people to be able to make arbitrary changes, you will need to enable your app bundle and redirect them to the client center.

The best way to do this so far is using SAML or Inbound Single-Sign-On for the authentication part. It looks like you should be able to do OpenId to access the client, but I haven't done that yet, so I don't know what pitfalls might occur along this route.

0


source







All Articles