Python API

Netsuite

class RPA.Netsuite.Netsuite

Netsuite is a library for accessing Netsuite using NetSuite SOAP web service SuiteTalk. The library extends the netsuitesdk library.

More information available at NetSuite SOAP webservice SuiteTalk.

Examples

Robot Framework

*** Settings ***
Library     RPA.Netsuite
Library     RPA.Excel.Files
Library     RPA.Tables
Task Setup  Authorize Netsuite

*** Tasks ***
Get data from Netsuite and Store into Excel files
    ${accounts}=        Get Accounts   account_type=_expense
    ${accounts}=        Create table    ${accounts}
    Create Workbook
    Append Rows To Worksheet  ${accounts}
    Save Workbook       netsuite_accounts.xlsx
    Close Workbook
    ${bills}=           Get Vendor Bills
    ${bills}=           Create table    ${bills}
    Create Workbook
    Append Rows To Worksheet  ${bills}
    Save Workbook       netsuite_bills.xlsx
    Close Workbook


*** Keywords ***
Authorize Netsuite
    ${secrets}=     Get Secret   netsuite
    Connect
    ...        account=${secrets}[ACCOUNT]
    ...        consumer_key=${secrets}[CONSUMER_KEY]
    ...        consumer_secret=${secrets}[CONSUMER_KEY]
    ...        token_key=${secrets}[CONSUMER_SECRET]
    ...        token_secret=${secrets}[TOKEN_KEY]

Python

from RPA.Netsuite import Netsuite

ns = Netsuite()
ns.connect()
accounts = ns.get_accounts()
currencies = ns.get_currencies()
ROBOT_LIBRARY_DOC_FORMAT = 'REST'
ROBOT_LIBRARY_SCOPE = 'GLOBAL'
connect(account: Optional[str] = None, consumer_key: Optional[str] = None, consumer_secret: Optional[str] = None, token_key: Optional[str] = None, token_secret: Optional[str] = None) None

Connect to Netsuite with credentials from environment variables.

Parameters are not logged into Robot Framework log.

Parameters
  • account – parameter or environment variable NS_ACCOUNT

  • consumer_key – parameter or environment variable NS_CONSUMER_KEY

  • consumer_secret – parameter or environment variable NS_CONSUMER_SECRET

  • token_key – parameter or environment variable NS_TOKEN_KEY

  • token_secret – parameter or environment variable NS_TOKEN_SECRET

get_accounts(count: int = 100, account_type: str = None) list

Get Accounts of any type or specified type.

Parameters
  • count – number of Accounts to return, defaults to 100

  • account_type – if None returns all account types, example. “_expense”, defaults to None

Returns

accounts

get_classifications() list

Get all Netsuite Classifications

Returns

classifications

get_currencies() list

Get all Netsuite Currencies

Returns

currencies

get_currency(currency_id: str) object

Get all a Netsuite Currency by its ID

Parameters

currency_id – ID of the currency to get

Returns

currency

get_departments() list

Get all Netsuite Departments

Returns

departments

get_locations() list

Get all Netsuite Locations

Returns

locations

get_vendor_bills(count: int = 10) list

Get list of vendor bills

Parameters

count – number of vendor bills to return, defaults to 10

Returns

list of vendor bills

get_vendors(count: int = 10) list

Get list of vendors

Parameters

count – number of vendors to return, defaults to 10

Returns

list of vendors

login(account: Optional[str] = None, email: Optional[str] = None, password: Optional[str] = None, role: Optional[str] = None, appid: Optional[str] = None) None

Login to Netsuite with credentials from environment variables

Parameters are not logged into Robot Framework log.

Parameters
  • account – parameter or environment variable NS_ACCOUNT

  • email – parameter or environment variable NS_EMAIL

  • password – parameter or environment variable NS_PASSWORD

  • role – parameter or environment variable NS_ROLE

  • appid – parameter or environment variable NS_APPID

netsuite_get(record_type: str = None, internal_id: str = None, external_id: str = None) list

Get all records of given type and internalId and/or externalId.

Parameters
  • record_type – type of Netsuite record to get

  • internal_id – internalId of the type, default None

  • external_id – external_id of the type, default None

Raises

ValueError – if record_type is not given

Returns

records as a list or None

netsuite_get_all(record_type: str) list

Get all records of given type.

Parameters

record_type – type of Netsuite record to get

Raises

ValueError – if record_type is not given

Returns

records as a list or None

Search Netsuite for value from a type. Default operator is contains.

Parameters
  • type_name – search target type name

  • search_value – what to search for within type

  • operator – name of the operation, defaults to “contains”

  • page_size – result items within one page, defaults to 5

Returns

paginated search object

netsuite_search_all(type_name: str, page_size: int = 20) PaginatedSearch

Search Netsuite for a type results.

Parameters
  • type_name – search target type name

  • page_size – result items within one page, defaults to 5

Returns

paginated search object