We are using the IntuitCDCResponse class of the .Net SDK for QuickBooks Online to retrieve a list of customer entitities that have changed within a specified period of time.
Currently, we are able to retrieve the list of changed customers and iterate the list. From this point, how can we tell whether or not the customer has been deleted in QuickBooks Online?
The docs say that when the entity has been deleted, the status
of the entity is set to Deleted
. We are assuming that this status is passed on to the status
property of the Customer
class in the SDK.
Here is the code we are currently attempting to use to determine if the Customer has been deleted.
if (customer.statusSpecified && customer.status == EntityStatusEnum.Deleted)
{
// handle deletion event locally
}
As it is, all Customer objects always have a statusSpecified
value of false and the status
value is always EntityStatusEnum.Deleted
, regardless of whether or not this is actually the case. We have repeatedly tested customers that have been updated, created and/or deleted.
We did attempt to search the SDK source code for hints about how the Customer class is being initialized, however it appears that the Intuit.IPP.Data namespace is not available in the source code.
This SO question is similar, and of some interest, but does not discuss how to correctly determine if the Customer has been deleted.
This is the best workaround I could come up with for now.
if ( (customer.statusSpecified && customer.status == EntityStatusEnum.Deleted)
|| customer.DisplayName.Contains("(deleted)") )
{
// handle deletion event locally
}
Or if you'd prefer to give up hope entirely of being able to determine the delete status the correct way...
if ( customer.DisplayName.Contains("(deleted)") )
{
// handle deletion event locally
}
QuickBooks Online appends the term "(deleted)" to the end of the Display Name when you mark a customer as inactive. This QuickBooks Help article is the closest I could come to documentation of this behavior. Under the section "To restore a customer" it states:
inactive customer will be noted as (deleted)