User Guide - nordic-netsuite/AVNS-CRUD GitHub Wiki

Parameters for POST call:

https://YOUR-INSTANCE-ID.netsuite.com/app/site/hosting/restlet.nl?script=X&deploy=Y
where
YOUR-INSTANCE-ID = can be seen in the adressbar when logged into your envionment
script X= AVNSCRUD script id in Netsuite
deploy Y= deployment id in Netsuite
The http url can be found in Netsuite under deployment of AVNSCRUD.


Parameters for Header

Following parameters must be provided in Header:

Parameter Comment
Consumer Key From Netsuite OAuth 1.0 configuration
Consumer Secret From Netsuite configuration
Token Key From Netsuite configuration
Token Secret From Netsuite configuration
Signature Method HMAC-SHAI
Realm Netsuite Account ID
Content/Type application/json
Host Depends on netsuite server (see your instance adress)

Parameters for body

Parameter Comment
action Mandatory
One of:
1. create: a record will be created in netsuite
2. read: a record will be returned from netsuite.
3. update: a record will be updated in netsuite
4. delete: a record will be deleted in netsuite
5.upsert: a record will be updated (if it exists) or created in netsuite
recordtype Mandatory
Record type.
Any custom or netsuite standard record type. Standard records can be found in NetSuite Record Browser.
customform Optional
internal id of the custom form to use in a “create” action
returntype One of:
1. record: a whole record is returned as a JSON structure
2. id: the id of the record is returned
3. externalid: the externalid of the record is returned
id Mandatory for “update”, “delete” and “read” (if externalid not provided) internal id of the record to update/delete/read
externalid Optional for “update”, “delete” and “read”
Mandatory for “upsert”
external id of the record to update/delete/read/upsert
fields Mandatory for “create”, “update” and “upsert”
fields:[{name:"field internal id",value:"field value",text:true/false},{...} ]
text parameter may be omitted (default is false)
text=true (value is a text) – text=false (value is numeric)

Fields of type List/Record may be referred to by externalid as follows:
fields:[{name:"field internal id",src:”record internal id”, externalid:”externalid of referred record"},{...} ]

Fields of type List/Record may be referred to by name as follows:
fields:[{name:"field internal id",src:”record internal id”, namesrc:”name of referred record"},{...} ]
sublists Optional parameter for “create” and “update”
JSON structure with sublist items
sublists parameter in a “create” call:
sublists:[id:"sublist internal id", rows:[{fields:[{name:"field internal id",value:"field value", text:true/false},{...}], {...}]]

Fields of type List/Record may be referred to by external id as follows:
sublists:[id:"sublist internal id", rows:[{fields:[{name:"field internal id",src:"record internal id",externalid:”externalid of referred record},{...}], {...}]]
Fields of type List/Record may be referred to by name as follows:
sublists:[id:"sublist internal id", rows:[{fields:[{name:"field internal id",src:"record internal id",namesrc:”name of referred record},{...}], {...}]]

Sublists parameter in an “update” call:
sublists:[id:"sublist internal id", rows:[{key: “field internal id”, keyvalue: “value of key”, fields:[{name:"field internal id",value:"field value",text:true/false},{...}], {...}]]
key: a field with unique values in sublist, used to identify which row to update
keyvalue: value of field in key

Fields of type List/Record may be referred to by external id as follows:
sublists:[id:"sublist internal id", rows:[{key: “field internal id”, keyvalue: “value of key”, fields:[{name:"field internal id",src:"record internal id",externalid:”externalid of referred record”},{...}], {...}]]

Fields of type List/Record may be referred to by name as follows:
sublists:[id:"sublist internal id", rows:[{key: “field internal id”, keyvalue: “value of key”, fields:[{name:"field internal id",src:"record internal id",namesrc:”name of referred record”},{...}], {...}]]

Restlet Answer

Property Comment
status One of:
“OK”: successful
“ERROR”: failure, the restlet call has failed to perform action
details []: if status “OK” otherwise
[{“code”: “error code”,“detail”: “description of error”}]
id Internal id of record created, read, updated or deleted
externalid Extenal id of record created, read, updated or deleted
record A JSON structure with the record created, read, updated or deleted

Example Body

Example 1: a simple call to read a record in Netsuite

{
	"action”: “read”,
	“recordtype": "salesorder",
	"returntype": "record",
	"id": “1234”
}

The sales order with id 1234 is returned by the restlet as a JSON structure

Example 2: a simple call to read a record in Netsuite using external id as key

{
	"action”: “read”,
	“recordtype": "salesorder",
	"returntype": "record",
	"externalid": “abcdef-x101”
}

The sales order with externalid “abcdef-x101” will be returned by the restlet as a JSON structure

Example 2.1: create a sales order in Netsuite with two item rows (and externalid reference)

{
	"action”: “create”,
	“recordtype": "salesorder",
	"returntype": "id",
	"fields":[
	{"name":"entity",value:"Testkund AB",text:true},
	{"name":"custbody_status",src:”customrecord_status”,externalid:”a1”}
	],
	“sublists":[
		{id:"item",
		rows:[
		{fields:[{"name":"item",value:45,text:false},
			{"name":"quantity",value:"2",text:false},
			]},
		{fields:[{"name":"item",value:"Accessories:Cable",text:true},
			{"name":"quantity",value:"10"},
			]},
		]}
	]
}

A sales order will be created and the internal id will be returned.
Note that field custobody_status is a List/Record field of type customrecord_status and it will be populated with the status with an externalid of “a1”.

Example 2.2: create a sales order in Netsuite with two item rows (and name reference)

{
	"action”: “create”,
	“recordtype": "salesorder",
	"returntype": "id",
	"fields":[
	{"name":"entity",value:"Testkund AB",text:true},
	{"name":"custbody_status",src:”customrecord_status”,namesrc:”Closed”}
	],
	“sublists":[
		{id:"item",
		rows:[
		{fields:[{"name":"item",value:45,text:false},
			{"name":"quantity",value:"2",text:false},
			]},
		{fields:[{"name":"item",value:"Accessories:Cable",text:true},
			{"name":"quantity",value:"10"},
			]},
		]}
	]
}

A sales order will be created and the internal id will be returned.
Note that field custobody_status is a List/Record field of type customrecord_status and it will be populated with the status having name = “Closed”.

Example 3: update a sales order in Netsuite with two item rows

{
	"action”: “update”,
	“recordtype": "salesorder",
	"returntype": "record",
	"id": "12345",
	"fields":[
		{"name":"memo",value:"Test Memo",text:true}
	],
	“sublists":[
		{id:"item",
		rows:[
		{key:”line”,
                keyvalue:”1”,
                fields:[{"name":"quantity",value:"10"}]},
		{key:”line”,
                keyvalue:”2”,
                fields:[{"name":"quantity",value:"20”}]},
		]}
	]	
}

Sales order with id = 12345 will be updated as follows:
memo field in header will get value “Test Memo”.
Quantity in line 1 will be updated to 10.
Quantity in line 2 will be updated to 20
The complete sales order will be returned in the answer as a JSON structure.

⚠️ **GitHub.com Fallback** ⚠️