0
votes

i want to get a top by top data, "100 first and 101 to 200 later", exist some way to Get like this with webservice on Acumatica?, because i only see into the API "topCount" Parameter and i only can get static number of data.

Please Help i dont know if this is posible with the web service

1

1 Answers

2
votes

Acumatica always export records via API sorted in ascending order by key fields. In order to export records in batches, you should simply combine $top parameter with additional GreaterThen condition(s) for last retrieved key field(s):

http://localhost/051989/entity/Default/6.00.001/StockItem?$top=10&$filter=InventoryID gt 'CONGOLFR1'

With combined $top and $skip parameters, Acumatica always first requests number of records specified by $top parameter, then excludes number of records specified by $skip parameter from beginning of resultset:

http://localhost/051989/entity/Default/6.00.001/StockItem?$top=10$skip=5

Skip parameter is not available with SOAP. To export records in batches with SOAP, you should combine LessThan condition for RowNumber property with GreaterThen condition(s) for last retrieved key field(s):

using (DefaultSoapClient client = new DefaultSoapClient())
{
    client.Login("login", "password", null, null, null);
    try
    {
        var items = client.GetList(
        new StockItem
        {
            RowNumber = new LongSearch
            {
                Condition = LongCondition.IsLessThan,
                Value = 10
            }
        },
        false);

        int count = items.Length;
        Console.WriteLine("InventoryID | Description | ItemClass | BaseUOM | LastModified");
        foreach (StockItem stockItem in items)
        {
            Console.WriteLine(
                string.Format("{0} | {1} | {2} | {3} | {4}",
                    stockItem.InventoryID.Value,
                    stockItem.Description.Value,
                    stockItem.ItemClass.Value,
                    stockItem.BaseUOM.Value,
                    stockItem.LastModified.Value));
        }

        while (items.Length == 10)
        {
            StockItem filter = new StockItem
            {
                RowNumber = new LongSearch
                {
                    Condition = LongCondition.IsLessThan,
                    Value = 10
                },
                InventoryID = new StringSearch
                {
                    Condition = StringCondition.IsGreaterThan,
                    Value = (items[items.Length - 1] as StockItem).InventoryID.Value
                }
            };

            items = client.GetList(filter, false);
            count = count + items.Length;
            foreach (StockItem stockItem in items)
            {
                Console.WriteLine(
                    string.Format("{0} | {1} | {2} | {3} | {4}",
                        stockItem.InventoryID.Value,
                        stockItem.Description.Value,
                        stockItem.ItemClass.Value,
                        stockItem.BaseUOM.Value,
                        stockItem.LastModified.Value));
            }
        }

        Console.WriteLine();
        Console.WriteLine(string.Format("Stock Items exported: {0}", count));
        Console.WriteLine();
    }
    finally
    {
        client.Logout();
    }
}