Tuesday, October 22, 2024

My requirement is to filter the datasource by adding conditions for a date range and grouping the results on the data source.

 [Form]

public class YNV_ResAvailabilityQueryForm extends FormRun

{

    [DataSource]

    class ResActivityResourceRequestReservationUnionView

    {

        /// <summary>

        ///

        /// </summary>

        public void executeQuery()

        {

            QueryBuildDataSource  queryBuildDataSource;

            TransDate              queryDate = today() + 30;

            QueryBuildRange              queryRange,taskNameRange;

 

            queryBuildDataSource = this.query().dataSourceTable(tablenum(ResActivityResourceRequestReservationUnionView));

            queryBuildDataSource.clearRanges();

            taskNameRange = queryBuildDataSource.addRange(fieldnum(ResActivityResourceRequestReservationUnionView, TaskName ));

            taskNameRange.value("Production");

            taskNameRange.status(RangeStatus::Locked);

            taskNameRange.status(RangeStatus::Hidden);

            

            queryRange = queryBuildDataSource.addRange(fieldnum(ResActivityResourceRequestReservationUnionView, EndTime ));

                queryRange.value(queryRange(dateNull(),queryDate));

            queryRange.status(RangeStatus::Locked);

            queryRange.status(RangeStatus::Hidden);


            // Set order mode to group by

            queryBuildDataSource.orderMode(OrderMode::GroupBy);


            // Add group by field

            queryBuildDataSource.addGroupByField(fieldNum(ResActivityResourceRequestReservationUnionView, Resource));


            // Add selection field for max EndTime

            queryBuildDataSource.addSelectionField(fieldNum(ResActivityResourceRequestReservationUnionView, EndTime), SelectionField::Max);


            super();

        }


    }

No comments:

Post a Comment

Resource Hard Booking Multithreading