ADO.NET Provider for QuickBooks Online

Build 24.0.9060

GETDELETED Statements

You can issue the GETDELETED query to retrieve all records deleted from the live data for the time range specified. This query accepts a datetime value as a filter. You can also use the statement without a filter.

When used on LineItem tables or other 'child entities', GETDELETED instead returns the parent records that have been modified rather than information about deleted child records. This is a limitation of the QuickBooks Online api.

GETDELETED FROM <table_name>
GETDELETED FROM <table_name> WHERE <search_condition>


<search_condition> ::= 
  {
    <expression> { = | < | <= | > | >= } [ <expression> ] 
  } [ { AND | OR } ... ]

<expression> ::=
  | @ <parameter> 
  | ?
  | <literal>
  

C#

String connectionString = "InitiateOAuth=GETANDREFRESH;";
using (QuickBooksOnlineConnection connection = new QuickBooksOnlineConnection(connectionString)) {
  QuickBooksOnlineCommand cmd = new QuickBooksOnlineCommand("GETDELETED FROM Customers WHERE [MetaData_LastUpdatedTime]>'2018-06-08T06:53:38-07:00'", connection); 
  QuickBooksOnlineDataReader rdr = cmd.ExecuteReader();
  while (rdr.Read()) {
    Console.WriteLine(rdr["Id"].ToString());
  }
}

VB.NET

Dim connectionString As [String] = "InitiateOAuth=GETANDREFRESH;"
Using connection As New QuickBooksOnlineConnection(connectionString)
  Dim cmd As New QuickBooksOnlineCommand("GETDELETED FROM Customers WHERE [MetaData_LastUpdatedTime]>'2018-06-08T06:53:38-07:00'", connection)
  Dim rdr As QuickBooksOnlineDataReader = cmd.ExecuteReader()
  While rdr.Read()
    Console.WriteLine(rdr("Id").ToString())
  End While
End Using
Note: By putting a CACHE command in front of the query, you can update the cache to remove all values that have been deleted from the data source. This is shown in the query below:
CACHE GETDELETED FROM [TableName]

Copyright (c) 2024 CData Software, Inc. - All rights reserved.
Build 24.0.9060