Query NoYes fields in AIF 4.0
7. February 2011 Leave a comment
found an interesting behavior in AX 4.0 AIF. Querying a document with a NoYes field e.g. InventLocation.Manual requires to use the value “Yes” to become TRUE but value “1” doesn’t work.
var client = new InventLocationServiceSoapClient();
client.ClientCredentials.Windows.ClientCredential.Domain = "insideax";
client.ClientCredentials.Windows.ClientCredential.UserName = "AifUser";
client.ClientCredentials.Windows.ClientCredential.Password = "********";
var context = new DocumentContext();
context.MessageId = Guid.NewGuid().ToString();
context.SourceEndpoint = "EXTAPP";
context.DestinationEndpoint = "APP";
var query = new QueryCriteria();
query.CriteriaElement = new CriteriaElement[1];
query.CriteriaElement[0] = new CriteriaElement();
query.CriteriaElement[0].DataSourceName = "InventLocation";
query.CriteriaElement[0].FieldName = "Manual";
query.CriteriaElement[0].Operator = Operator.Equal;
query.CriteriaElement[0].Value1 = "1";
var axdInventLocation = client.findListInventLocation(context, query);
Console.WriteLine(axdInventLocation.InventLocation == null);
// new guid
context.MessageId = Guid.NewGuid().ToString();
// change value
query.CriteriaElement[0].Value1 = "Yes";
axdInventLocation = client.findListInventLocation(context, query);
Console.WriteLine(axdInventLocation.InventLocation == null);
Console.ReadKey();
Result is shown here: