Knowledgebase
[QODBC-Desktop] - Optimizer Does Not Sync CustomFieldOther on SalesOrderLine Table
Posted by William - QODBC Support on 15 October 2026 08:18 AM

[QODBC-Desktop] - Optimizer Does Not Sync CustomFieldOther on SalesOrderLine Table

Problem Description:

When using QODBC to query the SalesOrderLine table, certain fields - most notably CustomFieldOther (which stores consolidation numbers or custom field values in QuickBooks) - may not appear in query results even though the data is visible in the QuickBooks Desktop UI. The QODBC Optimizer caches QuickBooks transaction data for performance, but it does not always detect changes made through the QuickBooks interface, causing stale or incomplete results.

Affected products: QODBC Desktop, QuickBooks Desktop (all editions)
Expected outcome: After forcing a sync of the QODBC Optimizer cache, or using the UNOPTIMIZED keyword, queries return all records including those with CustomFieldOther populated.

Symptoms:

  • A SQL query on SalesOrderLine with a WHERE CustomFieldOther = '<value>' clause returns fewer records than expected (e.g., only 2 out of 10 orders).
  • The missing records have the consolidation/custom field number visible in QuickBooks Desktop but are absent from QODBC query results.
  • Manually opening each sales order in QuickBooks and clicking "Send Email" (or any action button) causes the missing records to suddenly appear on subsequent queries.
  • Rebuilding the QODBC Optimizer temporarily resolves the issue, but it reappears after new orders are created or modified.
  • The issue also affects joined queries between SalesOrderLine, InvoiceLine, and SalesOrderLinkedTxn tables when filtering on custom field values.

Cause:

The QODBC Optimizer is designed to improve query performance by maintaining a local copy (cache) of QuickBooks transaction data. When the Optimizer cache is out of sync with the actual QuickBooks company file, queries return stale or incomplete results.

This issue specifically occurs because:

  1. Optimizer cache invalidation does not trigger on all QuickBooks UI actions. Creating or modifying a sales order in QuickBooks Desktop does not automatically notify the Optimizer that the underlying data has changed.
  2. CustomFieldOther is populated by QuickBooks during specific lifecycle events (e.g., sending an email, converting to invoice) and may not be visible to external applications until a sync occurs.
  3. The Optimizer relies on stored procedures or manual triggers to refresh its cache. Without explicit sync commands, the cached data remains unchanged even after QuickBooks updates.
Warning

This is a known limitation of the QODBC Optimizer architecture, not a bug. The Optimizer trades eventual consistency for performance - data becomes accurate only after a sync event. For real-time accuracy without cache dependencies, use the UNOPTIMIZED keyword in your queries.

Environment:

ProductVersion / Detail
QODBC Desktop All versions with Optimizer enabled
QuickBooks Desktop All editions (Pro, Premier, Enterprise)
Data Source Tools QODBC Test Tool, Crystal Reports, MS Access, Excel Power Query, MS SQL Server linked tables

Solution:

There are multiple approaches to resolve this issue, depending on your workflow and frequency of updates.

Method 1: Force an Optimizer Sync (Recommended for Production Use)

  1. Open the QODBC Test Tool. Navigate to Start → All Programs → QODBC Driver for QuickBooks → QODBC Test Tool.
  2. Run the optimizer update sync stored procedure for SalesOrder:
     sp_optimizeupdatesync SalesOrder
    This forces the Optimizer to pull the latest sales order data from QuickBooks, including any newly populated CustomFieldOther values.
  3. Run the optimizer update sync for Invoice (if applicable):
    sp_optimizeupdatesync Invoice
    If you are joining SalesOrder and Invoice data, syncing both ensures complete results.
  4. Execute your query again. The missing records with CustomFieldOther populated should now appear in the results.

Method 2: Perform a Full Optimizer Sync

  1. Open the QODBC Test Tool.
  2. Execute a full sync for the affected table:
    sp_optimizefullsync SalesOrder
    This rebuilds the entire Optimizer cache for the SalesOrder table, ensuring complete data consistency with QuickBooks.
  3. Wait for the sync to complete. Full sync may take longer for large company files.
  4. Test your query again.

Method 3: Use UNOPTIMIZED Queries (Immediate Fix, No Sync Required)

    1. Add the UNOPTIMIZED keyword to your query to bypass the Optimizer cache and read directly from QuickBooks:
SELECT RefNumber, CustomFieldOther FROM SalesOrderLine UNOPTIMIZED WHERE CustomFieldOther = 'CORB-0926'

Execute the query. Results will include all records with CustomFieldOther populated, regardless of Optimizer cache state.

Note

UNOPTIMIZED queries execute slower than Optimized queries because they bypass the local cache. Use this method for ad-hoc troubleshooting or when you need guaranteed real-time accuracy.

Method 4: Automate Sync in Your Application

  1. Schedule the optimizer sync stored procedures to run periodically (e.g., every few hours or before report generation) using a cron job, Windows Task Scheduler, or application-level timer.
  2. Example - automated daily sync at 6:00 AM:
    sp_optimizeupdatesync SalesOrder
    sp_optimizeupdatesync Invoice
    sp_optimizeupdatesync Customer
  3. Verify sync completion. Check the QODBC Messages log (QODBC Setup Screen → Messages → Review QODBC Messages) to confirm successful synchronization.

SQL Examples:

Basic Query with CustomFieldOther Filter

SELECT RefNumber, CustomFieldOther FROM SalesOrderLine WHERE CustomFieldOther = 'ENORA-0904'

Query Using UNOPTIMIZED to Bypass Cache

SELECT RefNumber, CustomFieldOther FROM SalesOrderLine UNOPTIMIZED WHERE CustomFieldOther = 'ENORA-0904'

Joining SalesOrder with InvoiceLine via LinkedTxn

SELECT
    SalesOrderLinkedTxn.TxnID,
    InvoiceLine.InvoiceLineItemRefFullName,
    InvoiceLine.InvoiceLineAmount
FROM SalesOrderLinkedTxn, InvoiceLine
WHERE SalesOrderLinkedTxn.CustomFieldOther = 'ADUNC-0918'
  AND SalesOrderLinkedTxn.LinkedTxnTxnID = InvoiceLine.TxnID
  AND InvoiceLine.InvoiceLineAmount <> 0

Query with DISTINCT on CustomFieldOther

SELECT DISTINCT RefNumber, CustomFieldOther FROM SalesOrderLine WHERE CustomFieldOther = 'ADUNC-0918'

Full Optimizer Sync Stored Procedure

sp_optimizefullsync SalesOrder

Example Scenarios:

Scenario 1 - Before the fix (Optimizer cache out of sync):

A user created 10 sales orders in QuickBooks with a consolidation number CORB-0926 in the CustomFieldOther field. Running the query:

SELECT RefNumber, CustomFieldOther FROM SalesOrderLine WHERE CustomFieldOther = 'CORB-0926'

returned only 3 orders. The remaining 7 orders were invisible because the Optimizer cache had not been updated since the orders were created.

Scenario 2 - After running sp_optimizeupdatesync:

The user executed sp_optimizeupdatesync SalesOrder from the QODBC Test Tool, then re-ran the same query. All 10 orders with consolidation number CORB-0926 now appeared in the results.

Scenario 3 - Using UNOPTIMIZED for immediate accuracy:

Without rebuilding or syncing the Optimizer, the user appended UNOPTIMIZED to the query and immediately got all 10 records. This is useful when a quick fix is needed without scheduling sync jobs.

Additional Notes:

  • Optimizer rebuild vs. sync: Rebuilding the Optimizer (via QODBC Setup → Optimize tab) clears and regenerates all cached data. Running sp_optimizeupdatesync or sp_optimizefullsync refreshes only specific tables without a full rebuild. Use stored procedures for routine maintenance; use rebuilds sparingly.
  • When CustomFieldOther changes: CustomFieldOther in QuickBooks is populated when users interact with certain fields on the sales order form (e.g., consolidation number field). The Optimizer may not detect these changes until a sync event occurs.
  • "Send Email" workaround: Clicking "Send Email" (or any action button) on a sales order in QuickBooks Desktop triggers an internal notification that updates the Optimizer cache for that specific record. This is why manually clicking through orders makes them appear, but it is not scalable for bulk data.
  • Cross-table joins: When joining SalesOrderLine with InvoiceLine or other tables, ensure all related tables are synced. Run sp_optimizeupdatesync on each table involved in the join.
  • Trace logs for troubleshooting: If syncing does not resolve the issue, enable Detail Trace Log (QODBC Setup → Messages tab → Enable 'Detail Tracing') and reproduce the issue. Share the trace log file (QODBCTRA.TXT in %AppData%\QODBC Driver for QuickBooks) with QODBC Support.
  • Performance consideration: Using UNOPTIMIZED queries on every execution will degrade performance significantly. Reserve UNOPTIMIZED for troubleshooting or occasional ad-hoc queries. Use stored procedure sync for regular operations.

Understanding QODBC Optimizer How to Rebuild the QODBC Optimizer Using UNOPTIMIZED Queries in QODBC QODBC Optimizer Sync Stored Procedures Reference Troubleshooting Missing Records in QODBC Queries

Keywords:

QODBC Optimizer CustomFieldOther SalesOrderLine Optimizer Sync sp_optimizeupdatesync sp_optimizefullsync UNOPTIMIZED Consolidation Number Missing Records SalesOrderLinkedTxn InvoiceLine QuickBooks Desktop Cache Invalidation Trace Log Crystal Reports Send Email Workaround
(0 vote(s))
Helpful
Not helpful

Comments (0)
Post a new comment
 
 
Full Name:
Email:
Comments:
CAPTCHA Verification 
 
Please complete the captcha below (we use this to prevent automated submissions).