Error 230: 'Index fields of table 1 must be fields in table 2'

When calling the Count endpoint, you might see the error 230.

When you are using the FetchData method to perform query manipulation and setting up of the SourceDefaultQuery. This method is not called when “Count” request is called.

Error message:

Error 230

'Index fields of table 1 must be fields in table 2'.

Solution:

FetchData is not executed as part of the Count request (CountResultRecords of the Data Access). There is however the method CustomizeFetchDataRequest

/** * Purpose: Hook method to support customization the IFetchDataRequest or ICountRecordsRequest * Notes: Centralized location to customize queries for FetchData and CountResultRecords * @param poFetchDataRequest The IFetchDataRequest instance to customize */ METHOD PROTECTED VOID CustomizeFetchDataRequest (poFetchDataRequest AS IFetchDataRequest): /* noop */ END METHOD.

Which is called from both the FetchData and CountResultRecords and can be used for centralized query manipulation code.

There is however a small pitfall: The CountResultRecords method does not yet reset the FetchDataArguments property to ? after the call. But that’s an enhancement you can make with ease. For now you will have to add a FINALLY block to your CountResultRecords methods:

FINALLY: ASSIGN THIS-OBJECT:FetchDataArguments = ? . END FINALLY