Deal All,
Today we are going to learn about how to set the count value on Tiles using x++ query. I came across this scenario during my resent customization. This will be helpful when you have requirement to filter tiles data count on the basis of unbound control of the form and that control value is not belongs to any of your dataSource columns.
Requirement: Add Integer control on the form and upon modification of that control update the count of Tile with the condition of records created before given number of days.
Logic: ((todays date - Created Date) > number of days given in the control) then show on the count otherwise not.
Implementation Steps :
- Create AOT query to show all the record count without number of days filter.
- Create Tile and set below 2 properties.
Query: query name
Type: count. - Create new form.
- Add new Integer filter control on the form and set auto declaration property to Yes. (No of Days)
- Add new Tile button on your form and set tile property with above created tile name.
- Override the getData() and clicked method of your Tile button and add below code.
{
#Task
super();
element.task(#taskRefresh);
}
public TileButtonControlData getData()
{
TileButtonControlData ret;
ret = super();
if(FilterNoOfDays.value() != 0)
{
int recordCOunt = element.countFromQuery(queryStr(TestTilePOLInes)); ret.strTileData(any2Str(recordCOunt));
}
}
7. add new method on form level with below code to get the count from query with No of days condition.
public Integer countFromQuery(str _query)
{
int totalRecords;
Query query = new Query(_query);
QueryRun qr = new QueryRun(query);
while (qr.next())
{
TESTAllPOLinesView dsTest = qr.get(tablenum(TESTAllPOLinesView));
int dateDiff = today() - DateTimeUtil::date(dsTest.CreatedDateTime1);
int filterValue = FilterNoOfDays.value();
if( dateDiff > filterValue)
{
totalRecords++;
}
}
return totalRecords;
}
8.Build and synch your project area and check the result by modifying the Number of days filter control.