Resource Finder dates are not in sorted chronological order when creating a new card with no projects or demands in the allocation workbench


Description

When a user creates a new card with no projects or demands in the allocation workbench, the resource finder dates are not displayed sorted in chronological order.

 

Steps to Reproduce

  1. Create a card in allocation workbench such that it should not have any project/demand.
  2. Create a resource plan.
  3. Go to the resource finder, observe the shown dates jump from Jan 2019 to Aug 2018 to Nov 2019.
  4. Play with the date toggle, observe this jumbles the dates even more.

Workaround

This problem has been fixed. If you are able to upgrade, review the Fixed In section to determine the latest version with a permanent fix your instance can be upgraded to.

If a workaround is needed, this consists in two steps:

- Change the below function _getRightSideColDefs in the 'ResourceGridColumnsForTask' Script Include:

 _getRightSideColDefs: function() {
    var plans;
    var dates;
    if (this.planIdList) {
        plans = ResourceGridQueries.getAllPlansFromPlanIds(this.planIdList);
    } else {
        if (this.taskId)
            plans = ResourceGridQueries.getAllPlans(this.taskId);
    }
    var gridDates = new ResourceGridDates(this.timeSpan);
    dates = ResourceGridQueries.getTaskStartAndEndDates(this.taskId, this.sysClass);
    gridDates.setTaskDates(dates[0], dates[1]);
    var dateRanges = gridDates.getGridDateRanges(plans);
    var startAndEndDates = gridDates.dateRange.computeRange(plans);
    this.finalPivotedDateRange = startAndEndDates;
    var startDates = dateRanges.map(RMDateRangeHelper.extractStartDate());
    var columns = ResourceGridMetadata.formatPivotColumnsToAgGrid(ResourceGridMetadata.REQUESTED_DAILY_ALLOCATION_PIVOT_COLUMNS);
    columns = columns.concat(ResourceGridMetadata.formatPivotColumnsToAgGrid(ResourceGridMetadata.RESOURCE_ALLOCATION_DAILY_PIVOT_COLUMNS));

    return ResourceGridPivotColumnFormatter.formatPivotColumns(startDates, this.timeSpan, columns);
}



- Change the below function _getPivotSortArray in the 'ResourceGridColDefsService' Script Include:

_getPivotSortArray: function(col, dateRange) {
    var pivotArr = [];
    var startDateTime = new GlideDateTime(dateRange.startDate);
    var endDateTime = new GlideDateTime(dateRange.endDate);
    startDateTime.addYearsUTC(-2);
    endDateTime.addYearsUTC(2);
    if (col == 'month') {
        startDateTime.setDayOfMonthUTC(1); //set date to first day of month
        while (startDateTime.getDate() <= endDateTime.getDate()) {
            pivotArr.push(this.getMonthFromDate(startDateTime));
            startDateTime.addMonthsUTC(1);
        }
    } else if (col == 'week') {
        var rmDateRangeHelper = new RMDateRangeHelper();
        rmDateRangeHelper.resetToWeekStartAndEnd(startDateTime, endDateTime);
        while (startDateTime.getDate() <= endDateTime.getDate()) {
            pivotArr.push(startDateTime.getDate().getDisplayValue());
            startDateTime.addDaysUTC(7);
        }
    }
    return pivotArr;
}

 


Related Problem: PRB1351550