Netsuite
Learn how to automate NetSuite operations using Abstra connectors through practical, focused tutorials.
Getting Started
Prerequisites
- NetSuite account with API access
- NetSuite credentials (Account ID, Consumer Key/Secret, Token ID/Secret)
- Abstra project
Quick Setup
- Add NetSuite connector in Abstra Console
- Enter your credentials
- Enable required resources:
suiteQL- Query datafileCabinet- File operationssoap- Attach operationsrest/purchaseOrder- Purchase order management
Test your connection:
from abstra.connectors import run_connection_action
result = run_connection_action(
"netsuite",
"query",
{"query": "SELECT COUNT(*) as total FROM vendor"}
)
print(f"✓ Connection works! Total vendors: {result['data']['items'][0]['total']}")
📁 File Cabinet Tutorials
Learn how to manage files in NetSuite File Cabinet:
1. Uploading Files
Upload files to NetSuite with proper encoding, folder management, and error handling.
You'll learn:
- Basic file upload
- Upload to specific folders
- Supported file types
- Batch uploads
- Error handling
# Quick example
with open("document.pdf", "rb") as f:
content = base64.b64encode(f.read()).decode('utf-8')
result = run_connection_action("netsuite", "add_file", {
"name": "document.pdf",
"content": content,
"fileType": "PDF"
})
2. Searching Files
Find files using SuiteQL queries with various search criteria.
You'll learn:
- Search by name, date, type, size
- Complex queries with multiple criteria
- Pagination techniques
- Count and aggregate queries
# Quick example
result = run_connection_action("netsuite", "query", {
"query": """
SELECT id, name, filesize
FROM File
WHERE name LIKE '%invoice%'
FETCH FIRST 10 ROWS ONLY
"""
})
3. Retrieving and Updating Files
Get file details, download content, update properties, and delete files.
You'll learn:
- Retrieve file information
- Download file content
- Update file properties
- Replace file content
- Delete files safely
- Bulk operations
# Quick example - get file details
file_details = run_connection_action("netsuite", "get_file", {
"fileId": "654321"
})
print(f"File: {file_details['data']['name']}")
4. Attaching Files to Records
Link files to purchase orders, invoices, customers, and other NetSuite records.
You'll learn:
- Attach files to different record types
- Upload and attach workflow
- Attach multiple files
- Share files across records
- Error handling
# Quick example
run_connection_action("netsuite", "attach", {
"attachTo": {"type": "purchaseOrder", "internalId": "501628"},
"attachedRecord": {"type": "file", "internalId": "654321"}
})
📋 Purchase Order Tutorials
Master purchase order operations in NetSuite:
1. Searching Purchase Orders
Find and filter purchase orders using various criteria.
You'll learn:
- Search by status, date, vendor
- Filter multiple statuses
- Group and aggregate
- Pagination for large datasets
- Build reusable search functions
# Quick example - find pending approval orders
result = run_connection_action("netsuite", "query", {
"query": """
SELECT t.id, t.tranid, t.trandate, ts.name as status
FROM transaction t
LEFT JOIN TransactionStatus ts ON t.status = ts.id
WHERE t.type = 'PurchOrd' AND ts.name = 'Pending Approval'
ORDER BY t.trandate DESC
"""
})
2. Reading Purchase Order Details
Retrieve complete purchase order information including all fields and relationships.
You'll learn:
- Get PO by ID or number
- Understand standard fields
- Parse approval status
- Read financial details
- Get vendor information
- Export to JSON/CSV
# Quick example - get complete PO details
result = run_connection_action("netsuite", "query", {
"query": """
SELECT t.*, ts.name as status_name, v.companyname as vendor_name
FROM transaction t
LEFT JOIN TransactionStatus ts ON t.status = ts.id
LEFT JOIN vendor v ON t.entity = v.id
WHERE t.tranid = 'PO2024-001' AND t.type = 'PurchOrd'
"""
})
3. Filtering by Custom Fields
Search and filter purchase orders using company-specific custom fields.
You'll learn:
- Discover available custom fields
- Filter by department, cost center, project
- Search by approver or creator
- Filter by amount ranges
- Handle NULL custom fields
- Build flexible search functions
# Quick example - filter by department and approver
result = run_connection_action("netsuite", "query", {
"query": """
SELECT t.id, t.tranid, t.custbody7 as department,
t.custbody15 as approver, ts.name as status
FROM transaction t
LEFT JOIN TransactionStatus ts ON t.status = ts.id
WHERE t.type = 'PurchOrd'
AND t.custbody7 = '5'
AND t.custbody15 = '789'
AND ts.name = 'Pending Approval'
"""
})
4. Creating Purchase Orders
Complete workflow for creating purchase orders and attaching supporting documents.
You'll learn:
- Query for required IDs (vendors, items, subsidiaries)
- Create purchase orders via REST API
- Upload files
- Attach files to purchase orders
- Handle errors
- Complete end-to-end workflow
# Quick example - create PO
po_result = run_connection_action("netsuite", "post_purchase_order", {
"data": {
"entity": {"id": vendor_id},
"subsidiary": {"id": subsidiary_id},
"tranDate": "2025-01-01",
"item": {
"items": [{
"item": {"id": item_id},
"quantity": 10,
"rate": 50.00
}]
}
}
})
Common Patterns
Upload and Attach Pattern
import base64
# 1. Upload file
with open("contract.pdf", "rb") as f:
content = base64.b64encode(f.read()).decode('utf-8')
file_result = run_connection_action("netsuite", "add_file", {
"name": "contract.pdf",
"content": content,
"fileType": "PDF"
})
# 2. Attach to record
run_connection_action("netsuite", "attach", {
"attachTo": {"type": "purchaseOrder", "internalId": po_id},
"attachedRecord": {"type": "file", "internalId": file_result['data']['id']}
})
Search and Process Pattern
# 1. Find files
files = run_connection_action("netsuite", "query", {
"query": "SELECT id, name FROM File WHERE name LIKE '%invoice%'"
})
# 2. Process each file
for file in files['data']['items']:
details = run_connection_action("netsuite", "get_file", {
"fileId": str(file['id'])
})
# ... process file
Bulk Operations Pattern
def process_files_in_batches(file_ids, operation, batch_size=10):
for i in range(0, len(file_ids), batch_size):
batch = file_ids[i:i + batch_size]
for file_id in batch:
run_connection_action("netsuite", operation, {"fileId": file_id})
time.sleep(1) # Rate limiting
Quick Reference
File Operations
| Action | Purpose | Key Parameters |
|---|---|---|
add_file | Upload file | name, content, fileType |
get_file | Get file details | fileId |
update_file | Update file | fileId, fields to update |
delete_file | Delete file | fileId |
attach | Attach file to record | attachTo, attachedRecord |
query | Search files | query (SuiteQL) |
Common File Types
| Type | Value |
|---|---|
PDF | |
| Excel | EXCEL |
| Word | WORD |
| Plain Text | PLAINTEXT |
| JavaScript | JAVASCRIPT |
| CSV | CSV |
| PNG | PNGIMAGE |
| JPEG | JPGIMAGE |
Common Record Types
| Record | Type Value |
|---|---|
| Purchase Order | purchaseOrder |
| Sales Order | salesOrder |
| Invoice | invoice |
| Vendor Bill | vendorBill |
| Customer | customer |
| Vendor | vendor |
Best Practices
File Naming
# ✅ Good: Descriptive with date
f"invoice_vendor123_{datetime.now().strftime('%Y%m%d')}.pdf"
# ❌ Bad: Generic
"document.pdf"
Error Handling
try:
result = run_connection_action("netsuite", "add_file", params)
except Exception as e:
print(f"Error: {str(e)}")
Base64 Encoding
# ✅ Always use binary mode
with open("file.pdf", "rb") as f:
content = base64.b64encode(f.read()).decode('utf-8')
SuiteQL Queries
# ✅ Use FETCH FIRST (not LIMIT)
"SELECT id FROM File FETCH FIRST 10 ROWS ONLY"
# ✅ File types have underscore prefix
"WHERE filetype = '_PDF'"
Troubleshooting
"Action attach not found"
- Enable
soapresource in your NetSuite connection configuration
"File size exceeds limit"
- NetSuite SOAP API has a 10MB file size limit
"Invalid file type"
- Ensure
fileTypeparameter matches actual file content - Use uppercase:
PDF,EXCEL,PLAINTEXT
"Unknown identifier" in SuiteQL
- Use
FETCH FIRST N ROWS ONLYinstead ofLIMIT N - File types in queries need underscore:
_PDF,_EXCEL
"Permission denied"
- Check NetSuite role has File Cabinet permissions
- Verify user has Attach Files to Records permission
Resources
- NetSuite SuiteQL Documentation
- NetSuite REST API Guide
- NetSuite SOAP API Guide
- Abstra Connectors Reference
Need Help?
- Check the specific tutorial for detailed examples
- Review error messages in troubleshooting sections
- Test with small files first
- Verify credentials and permissions