SuitePortal
User GuideSyncing Data

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 IDTypeApplied To
custbody_sp_flagCheckboxTransaction body (orders, invoices, etc.)
custentity_sp_flagCheckboxEntity 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 SuitePortal

When a sync runs:

  1. NetSuite saved search filters for flagged records
  2. Map/Reduce script processes matching records
  3. Records are posted to SuitePortal ingest API
  4. Optionally, flag can be cleared after successful sync

Flagging Entities

For customer, vendor, and contact records:

  1. Open the entity record in NetSuite
  2. Find the SuitePortal Flag checkbox (custentity_sp_flag)
  3. Check the box
  4. Save the record

The record will be included in the next sync run.

Flagging Transactions

For sales orders, invoices, purchase orders, and item fulfillments:

  1. Open the transaction record in NetSuite
  2. Find the SuitePortal Flag checkbox (custbody_sp_flag)
  3. Check the box
  4. Save the record

Bulk Flagging

To flag multiple records at once in NetSuite:

Via Mass Update

  1. Navigate to Lists → Mass Update → Mass Updates
  2. Select the record type
  3. Set criteria to identify records to flag
  4. Set custbody_sp_flag or custentity_sp_flag to true
  5. Run the mass update

Via CSV Import

  1. Export records to CSV
  2. Add flag column with value T (true)
  3. 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

  1. Create a workflow on the record type
  2. Add condition (e.g., status = approved)
  3. 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:

FilterValue
custbody_sp_flagis true (for transactions)
custentity_sp_flagis true (for entities)

Clearing Flags After Sync

To prevent re-syncing the same records, you can clear flags after successful sync:

  1. Enable "Clear flag on sync" in the sync configuration
  2. 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