Query NoYes fields in AIF 4.0

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:

image

About erpcoder
Software Engineer and Dynamics AX enthusiast working in Research & Development for InsideAx

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: