Syncing New and Updated QuickBooks Records on a Schedule
Developers using the Web Connector SDK can automatically pull recently modified customers, estimates, and sales orders by registering a login hook and queuing recurring queries.
QuickBooks desktop integrations built on the PHP Web Connector toolkit generally run smoothly, but a common question among developers is how to detect when customers, estimates, or sales orders have been created or modified in the company file so those changes can be pushed to an external server. The challenge is setting up the integration to check for these changes automatically each time the Web Connector initiates a sync session, without resorting to full database mirroring.
The recommended approach does not require mirroring at all. Instead, it relies on a built-in hook system that triggers specific functions at key points during the connection process. By registering a login success hook, the integration can execute logic every time the Web Connector successfully authenticates and begins a new session.
Hooking Into the Login Event
The mechanism works by mapping a login success event to a custom function. When the Web Connector logs into QuickBooks and the connection is verified, the toolkit calls that function. Inside this function, the developer can access the internal queue and add tasks to it. For example, every time a session starts, the function can enqueue a request to import customers. The queue then processes that request during the current sync cycle.
To manage timing, the toolkit supports a “last run” timestamp for each queued action. The login hook function checks whether a last run time has been stored. If none exists — as is the case for a brand-new integration — it sets a default historical timestamp. This ensures the first sync pulls records from a reasonable starting point rather than missing historical data.
Building the Query for Modified Records
Once a task is queued, the integration needs request and response handlers. The request handler constructs a query that asks QuickBooks for records modified after a specific timestamp. That timestamp is drawn from the last run value, which the handler retrieves and immediately updates to the current time. This ensures the next sync picks up only records changed since the previous run.
The query itself specifies a maximum number of records to return per batch — twenty is a practical default — and filters by the modified date. It also includes an owner identifier so that custom fields and linked data are returned alongside the core record.
Handling Large Result Sets
QuickBooks may return more modified records than a single batch can accommodate. The toolkit addresses this through iterator support. When the response handler receives a batch and detects that additional records remain — indicated by a remaining count attribute in the response — it enqueues a follow-up request using an iterator identifier. That follow-up uses a “continue” flag rather than “start,” telling QuickBooks to resume where the previous batch left off. The handler reads the stored current run timestamp to maintain the same modified-date window across all batches in the sequence.
This pattern repeats until the remaining count reaches zero, at which point all modified records for that entity type have been retrieved and processed. The same structure applies whether the integration is querying customers, estimates, sales orders, or other list and transaction types.
Practical Considerations
For integrations that need to track multiple entity types, the login hook can enqueue separate tasks for each — customers, estimates, and sales orders each get their own queued request with its own last run timestamp. Priority levels can be assigned to control the order in which QuickBooks processes them during the session.
This approach keeps the integration lightweight. Rather than maintaining a full mirror of the QuickBooks database, the server receives only the records that have changed since the last sync. The login hook ensures the checks happen automatically on every connection, and the iterator mechanism guarantees that no modified records slip through when large batches of changes occur. For troubleshooting broader connection or data issues during integration development, QuickBooks Desktop help resources can provide additional context.