web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :

How to set count on Tile using X++ (Update tile count runtime)

Vijay Yelmame VY Profile Picture Vijay Yelmame VY 468

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.

Formula: ((todays date  - Created Date) > number of days given in the control) then show on the count otherwise not.

Implementation Steps :

  1. Create AOT query to show all the record count without number of days filter.
  2. Create Tile and set Query property with recently created query name, Type property to count.
  3. Create new form.
  4. Add new Integer filter control on the form and set auto declaration property to Yes. (No of Days)
  5. Add new Tile button on your form and set tile property with recently created tile name.
  6. Override the getData() and clicked method of your Tile button and add below code.
public void clicked()
{
    #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));     
        return ret;
    }
}

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.
 


This was originally posted here.

Comments