question

bartram avatar image
bartram asked zgreathouse Deactivated edited

OrderContract stopped returning/filtering by customer named

In our app, we use the Android SDK CursorLoader class to search Orders by customer name. Recently, the query for a customer name stopped working, and getting orders from the OrderConnector also doesn't include a customer name. For example, in the Loader manager, the onCreateLoader function returns a CursorLoader like this:
override fun onCreateLoader(id: Int, args: Bundle?): Loader<Cursor> {
    val account = CloverAccount.getAccount(context)
    val uri = OrderContract.Summaries.contentUriWithAccount(account)
    val selection = "customer_name LIKE %"
    val selectionArgs = arrayOf("%foo%")
    return CursorLoader(
            this,
            uri,
            null,
            selection,
            selectionArgs,
            null
    )
}
The loader won't return any orders, even if there is a customer named "foo". Omitting the selection and selectionArgs arguments does return orders. However, when trying to load one of those orders and view the name of the customer for that order, the customer name is null. For example:
val orderConnector = OrderConnector(context, account, null)
orderConnector.connect()
val order = orderConnector.getOrder(orderId)
order.customers[0].id // this returns a value
order.customers[0].firstName // this is null
order.customers[0].lastName // this is also null
Using the REST API to get the customer (/v3/merchants/[ merchantID ]/customers/[ customerID ]), I can see that the first and last name is valid for the customer. However, I can no longer get the name from the order using the OrderConnector in the Android SDK.

Both of these behaviors worked several weeks ago (querying by customer name using the OrderContract uri, and getting customer name from orders with OrderConnector).
Clover Android SDK
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
zgreathouse avatar image
zgreathouse Deactivated answered zgreathouse Deactivated edited
I have been able to reproduce the issue. What I believe is going on here is the Order's nested fields are not being updated on the device's local database. So when you fetch the order you are not getting the up to date customer record, as this data is housed in a nested field of the Order.

(For the above to be true, what must have happened is that at the time the customer was associated with the order, the customer record did not have a firstName or lastName. However the customer record was updated after the fact.)

To get this data to sync on device manually, you can go to the order show page in the Clover orders app (on device). By simply navigating to this show page the order will be updated with the up to date customer record, due to a thorough sync which occurs.
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community