Jim
Jim

Reputation: 28

What is the right way of filtering an Export on Acumatica Web Services?

I just tested the example code on how to export with filters on Acumatica with Web Services. But it is completely ignoring the filters.

DateTime syncDate = new DateTime(2016, 1, 1);
WebReference.Screen context = new WebReference.Screen();
context.CookieContainer = new System.Net.CookieContainer();
context.AllowAutoRedirect = true;
context.EnableDecompression = true;
context.Timeout = 1000000;
context.Url = "http://<MYACUMATICAINSTANCE>/(W(64))/Soap/IN202500.asmx";
context.Login("<MYUSER>", "<MYPASS>");
WebReference.Content IN202500 = context.GetSchema();
context.Clear();
string[][] result = context.Export(
    new WebReference.Command[]{
        IN202500.StockItemSummary.ServiceCommands.EveryInventoryID,
        IN202500.StockItemSummary.InventoryID,
        IN202500.StockItemSummary.Description,
        IN202500.WarehouseDetails.WarehouseWarehouseID,
        IN202500.WarehouseDetails.QtyOnHand
    },
    new WebReference.Filter[]{
        new WebReference.Filter { Field = new WebReference.Field { ObjectName = IN202500.StockItemSummary.ItemStatus.ObjectName, FieldName = IN202500.StockItemSummary.ItemStatus.FieldName }, Condition = WebReference.FilterCondition.Equals, Value = "Activse", Operator = WebReference.FilterOperator.And },
        new WebReference.Filter { Field = new WebReference.Field { ObjectName = IN202500.StockItemSummary.InventoryID.ObjectName, FieldName = "LastModifiedDateTime" }, Condition = WebReference.FilterCondition.Equals, Value = syncDate.ToLongDateString(), Operator = WebReference.FilterOperator.And }
    },
    5, false, false
);
foreach (string[] item in result)
{
    Console.WriteLine(
        item[0] + ";" +
        item[1] + ";" +
        item[2] + ";" +
        item[3] + ";"
    );
}

Notice the bad syncDate and bad condition value Activse for bad filtering, it should return no results, but instead it returns all results.

Upvotes: 1

Views: 345

Answers (1)

Spyder045
Spyder045

Reputation: 121

I found that the filters do not work properly on the default screens. If you create a Generic Inquiry you can specify filters and shrink your result set down to the fields you need. Also, the GI screens typically run faster than the standard default screens.

Upvotes: 2

Related Questions