Connecting to NetSuite
Connecting to NetSuite
Connecting to NetSuite is fairly straightforward. Simply provide the User, Password, and AccountId properties to connect. It is also recommended but not required to specify the RoleId and NetsuiteMetadataFolder: if RoleId is empty, the user's default role is used. The Netsuite Metadata Folder is a folder on disk where NetSuite metadata files will be stored. If you do not specify one, a folder location will be selected automatically. To ensure fast load times when listing metadata about tables, it is best to set this property.
NetSuite Web Services Permissions
The driver communicates with NetSuite through the NetSuite Web services. This means that the user specified in the connection must have permissions on the specified AccountId to connect through NetSuite Web services. If the user does not already have Web services permissions, an exception stating "You do not have permission to access Web services features" will be thrown when trying to connect. If this happens, an administrator will need to grant Web services permissions to the user by doing the following:
1. Create a Web services role
- Log into NetSuite and under Setup go to User/Roles -> Manage Roles -> New.
- Click Permissions -> Setup and add the "Web Services" role.
- Add other permissions that are needed for interacting with various entities and transactions.
- Under Setup, go to User/Roles -> Manage Users and select the user.
- On the Access tab, add the newly created role and save the user.
- Log into NetSuite and under Setup go to Integration -> Web Service Preferences.
- Select the user in the Name menu. In the Web Services Default Role menu, select the newly created role.
- Click add and save to save changes.
By default, NetSuite allows users to establish only one session when connecting to NetSuite at a time. If a second session is started, then the first session will be invalidated. For this reason, we default UseSessions to false. This will cause each request to be its own session. If you set UseSessions to true, be careful to close each connection before starting a new one. Otherwise you may receive an exception that your session has timed out. Please note that some UI editors take up multiple connections, and setting UseSessions to true will cause this exception in this scenario.
By default, NetSuite allows only one requst at a time for a given user. If a request is still executing against NetSuite when another one is attempted, an error stating "Only one request may be made against a session at a time" will be thrown on the second connection.
NetSuite Response Times
NetSuite response times can take a long time depending on what you are retrieving. This can range from 20-40 seconds to retrieve 1000 SalesOrders to up to 8-12 minutes to retrieve a single page of the SalesOrder_ItemList. The main factor that can affect performance is whether or not child table information is retrieved. For instance, the SalesOrder_ItemList table would be considered the child table of SalesOrder. In addition, the information in the ItemListAggregate on the SalesOrder table would be considered child table information. Because of the significant delay it adds in response times from NetSuite, we have defaulted AggregateColumnMode to Ignore. When set to either Ignore or List, this will cause any Aggregate columns on base tables such as SalesOrder to not request data from NetSuite. This property has no effect on child tables.
Slow NetSuite response times extend to inserts, updates, and deletes as well. This can be especially noticable when using the INSERT INTO SELECT Statements, UPDATE SELECT Statements, or DELETE SELECT Statements syntax. When inserting, updating, or deleting multiple records at a time, it may be worthwhile to set UseAsyncServices to true. This will cause the request to be processed asynchronously on NetSuite's end and a JobId will be returned in the Info#TEMP table. The JobId can be checked against the stored procedures CheckJobStatus and GetJobResults for information about when the job is completed, if any errors occurred, and for the InternalIds for newly created entities.