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
23 stars 33 forks source link

nodejs query question #75

Closed yosiasz closed 2 years ago

yosiasz commented 2 years ago

Greetings, spent couple of days trying to sort the following out

nodejs 12.22.3
OS: Windows 10

the following code works when removing the filter.

        const query = new IA.Functions.Common.ReadByQuery();
        let where = new IA.Functions.Common.Query.Comparison.Like.LikeString();

        where.field = "asset_tag";
        where.value = "Power";
        query.query = where;

        getAssets(client, query);

But with the filter on, it returns 0 results, where am I fumbling the rock?

Thanks!

yosiasz commented 2 years ago

needed the following, was querying the wrong field :(

         const IA = require("@intacct/intacct-sdk");      
        const sessionConfig = await getSession();

        const client = new IA.OnlineClient(sessionConfig);

        const query = new IA.Functions.Common.ReadByQuery();                          
        query.objectName = "asset";
        query.pageSize = 1000; // Keep the count to just 1 for the example
        query.fields = [
            "name",
            "asset_name",
            "asset_tag",
            "serial_number"            
        ];

        let where = new IA.Functions.Common.Query.Comparison.Like.LikeString();
        where.field = "asset_name";
        where.value = "Power%";  

        query.query = where;         

        const response = await client.execute(query);