Posts

Showing posts from March, 2015

Dynamics AX - AIF, Using Asterix (wild card character) in an Criteria Element Find method

Image
W hen consuming AIF services via c#, a common ask is can we write a query similar to a Like statement in SQL. Statements like this one should be possible: (C#) var criteriaElements = new AXCSICustomer.CriteriaElement[1]; criteriaElements[0] = new AXCSICustomer.CriteriaElement(); criteriaElements[0].DataSourceName = "DirParty"; criteriaElements[0].FieldName = "Name"; criteriaElements[0].Operator = AXCSICustomer.Operator.Equal; criteriaElements[0].Value1 = " *bob* "; var queryCritieria = new AXCSICustomer.QueryCriteria() {     CriteriaElement = criteriaElements }; While you can use the '?' wildcard in the  value, AX will strip any other special characters (specifically *",.()<>!= characters).  This happens in the class SysQuery::value() method in AX. One workaround, as found here , is to use the GreaterOrEqual operator.  This essentially turns the query into a "starts with" statement. (C#) criter