Flagging Records for Sync
Use custom fields in NetSuite to control which records sync
Flagging Records for Sync
SuitePortal uses custom checkbox fields in NetSuite to control which records are included in syncs. This allows you to selectively sync records rather than syncing your entire database.
Custom Fields
The SuiteBundle creates two custom fields for flagging:
| Field ID | Type | Applied To |
|---|---|---|
custbody_sp_flag | Checkbox | Transaction body (orders, invoices, etc.) |
custentity_sp_flag | Checkbox | Entity records (customers, vendors, contacts) |
How Flagging Works
NetSuite Record SuitePortal
│ │
├─ custbody_sp_flag = true │
│ OR custentity_sp_flag = true │
│ │
└─ Included in saved search ──► Synced to SuitePortalWhen a sync runs:
- NetSuite saved search filters for flagged records
- Map/Reduce script processes matching records
- Records are posted to SuitePortal ingest API
- Optionally, flag can be cleared after successful sync
Flagging Entities
For customer, vendor, and contact records:
- Open the entity record in NetSuite
- Find the SuitePortal Flag checkbox (
custentity_sp_flag) - Check the box
- Save the record
The record will be included in the next sync run.
Flagging Transactions
For sales orders, invoices, purchase orders, and item fulfillments:
- Open the transaction record in NetSuite
- Find the SuitePortal Flag checkbox (
custbody_sp_flag) - Check the box
- Save the record
Bulk Flagging
To flag multiple records at once in NetSuite:
Via Mass Update
- Navigate to Lists → Mass Update → Mass Updates
- Select the record type
- Set criteria to identify records to flag
- Set
custbody_sp_flagorcustentity_sp_flagtotrue - Run the mass update
Via CSV Import
- Export records to CSV
- Add flag column with value
T(true) - Import using NetSuite CSV import
Via SuiteScript
// Example: Flag all customers in subsidiary 1
var customerSearch = search.create({
type: search.Type.CUSTOMER,
filters: [['subsidiary', 'anyof', '1']],
columns: ['internalid']
});
customerSearch.run().each(function(result) {
record.submitFields({
type: record.Type.CUSTOMER,
id: result.id,
values: { custentity_sp_flag: true }
});
return true;
});Automatic Flagging
You can set up workflows or user event scripts to automatically flag records:
On Create/Edit Workflow
- Create a workflow on the record type
- Add condition (e.g., status = approved)
- Add action to set flag field to true
User Event Script
/**
* @NApiVersion 2.1
* @NScriptType UserEventScript
*/
define(['N/record'], function(record) {
function afterSubmit(context) {
if (context.type === context.UserEventType.CREATE) {
record.submitFields({
type: context.newRecord.type,
id: context.newRecord.id,
values: { custentity_sp_flag: true }
});
}
}
return { afterSubmit: afterSubmit };
});Saved Search Configuration
The sync Map/Reduce scripts use saved searches to find flagged records. Ensure your saved searches include:
| Filter | Value |
|---|---|
custbody_sp_flag | is true (for transactions) |
custentity_sp_flag | is true (for entities) |
Clearing Flags After Sync
To prevent re-syncing the same records, you can clear flags after successful sync:
- Enable "Clear flag on sync" in the sync configuration
- After successful ingest, the Map/Reduce script sets flag to
false
Note: This is optional. If disabled, records with flags will sync on every run (idempotent upsert).
Next: Scheduling Syncs