intacct / intacct-sdk-js

Official repository of the Sage Intacct SDK for JavaScript in Node.js
https://developer.intacct.com/tools/sdk-node-js/
Apache License 2.0
22 stars 31 forks source link

ReadByQuery not finding RECORDID #123

Closed kpiercy closed 6 months ago

kpiercy commented 10 months ago

Inside our Intacct integration I have an initial check using ReadByQuery that checks for a RECORDID to see if it exists prior to trying to create one. This check works fine for a RECORDID like 142507, but our system also passes a "-P" on some invoices. When using ReadyByQuery to search for "142507-P", the API is returning a _count of 0, where the record definitely exists inside the system.

Excerpt from our function: `let read = new IA.Functions.Common.ReadByQuery() read.objectName = 'ARINVOICE' read.fields = ['*'] read.query = new IA.Functions.Common.Query.QueryString( 'RECORDID = ' + invNum //invNum = 142507-P )

        logger.info('Executing ReadByQuery to Intacct API')
        const response = await client.execute(read)
        const result = await response.getResult()
        return result`
kpiercy commented 6 months ago

Fix for this issue was found: https://github.com/intacct/intacct-sdk-js/issues/75#issuecomment-946220025

Switched from using Common.Query.QueryString to using Common.Query.Comparison.Like.LikeString():

let read = new IA.Functions.Common.ReadByQuery()
read.objectName = 'ARINVOICE'
read.fields = ['*']

let where = new IA.Functions.Common.Query.Comparison.Like.LikeString()
where.field = 'RECORDID'
where.value = `%${invNum}%`

read.query = where
kpiercy commented 6 months ago

Solution above.