Thursday, September 15, 2011

Add complex conditions in AOT Query in Dynamics X++

Sometimes you need to add complex conditions in your query to acheive the requirement. Below example will help you to achieve this

So i want to add these condition on query
BudgetSourceTracking.Category == BudgetControlCategory::Original || ( BudgetSourceTracking.Category == BudgetControlCategory::CarryForwardBudget && BudgetSourceTracking.Status == BudgetSourceTrackingStatus::Confirmed) || ( BudgetSourceTracking.Category != BudgetControlCategory::Original && BudgetSourceTracking.Category != includeCarryForward)
rangeCrtiteria is any string data type, you notice that i have added the condition of Status field too, but its alos working in this case
 rangeCriteria = strfmt('((((%1.%2 == %3) || ((%1.%2 == %4) && %7)) && (%1.%5 == %6)) || ((%1.%2 != %3) && (%1.%2 != %4)))',
query.dataSourceTable(tablenum(BudgetSourceTracking), 1).addRange(fieldnum(BudgetSourceTracking, Category)).value(rangeCriteria);
queryRun = new QueryRun(query);

How to add date range in query at run time in Dynamics AX, X++

It want to add the date range on the query at run time. how can i achieve this.


query.dataSourceTable(tablenum(BudgetSourceTracking), 1).addRange(fieldnum(BudgetSourceTracking, TrackingDate)).value(queryRange( fiscalPeriodStartDate, fiscalPeriodEndDate));

Format the Phone number in the Dynamics AX - X++

The string control in the MorphX does not provide the functionality or any masking to format the phone number but it can be acheivied by saving the data in the format you need at the table level.

the link of blog will definitely helpful for achiveing this

Phone number formatting