Fixing Timeless Activity Displays in the Infor CRM 8.3.09 Web Client

In the Infor CRM 8.3.09 web client timeless activities in the sdata grid display their dates as one day off due to UTC offset incorrectly being applied to these records. The sdata grids all inherit from the Sage.UI.Controls.GridParts.Columns.DateTime widget. Because of this we can fix the base widget function returning the incorrect date value and it will effect all of the grids in the Web Client.

Using Ryan’s custom loader module all that is required is to create a new folder under the Custom/Modules area. I would suggest something like “TimelessActivityFix”. Then in this folder add a main.js with the following code:

require([
	'Sage/UI/Controls/GridParts/Columns/DateTime',
	'dojo/date/locale',
	'Sage/Utility',
	'Sage/Utility/Activity',
	'dojo/_base/declare',
	'dojo/_base/lang',
	'dojo/aspect',
	'dojo/dom-construct'
],
function (
	dateTime,
	locale,
	Utility,
	activityUtility,
	declare, 
	lang,
	aspect,
	domConstruct 
) {
	var convert = Utility.Convert;
	lang.extend(dateTime, {
	formattedDate: function (inRowIndex, inItem) {
            // summary:
            //	if given a date, convert it to local time and provide corresponding HTML
            if (!inItem)
                return '';
            var d = inRowIndex ? inRowIndex : this.defaultValue;

            this.dateOnly = (typeof this.dateTimeType === 'undefined') ? this.dateOnly : (this.dateTimeType.toUpperCase() === 'D');

            if (!d)
                return '';
            d = convert.toDateFromString(d, true);
            if (!d || d.constructor !== Date) {
                return '';
            }
            var tless = false;
            if (this.timelessField && this.timelessField !== '') {
                tless = convert.toBoolean(Utility.getValue(inItem, this.timelessField, 'F'));
            }
            if (this.useFiveSecondRuleToDetermineTimeless) {
                tless = activityUtility.isDateFiveSecondRuleTimeless(d);
            }
            // TODO: edit mode?    
            if (!this.dateOnly && !this.datePattern) {
                if (!tless) {
                    return locale.format(d, { selector: this.formatType || 'date/time', fullYear: true, locale: Sys.CultureInfo.CurrentCulture.name });
                } else {
                    var timelessDate = new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), 0, 0, 5);
                    return dojo.date.locale.format(timelessDate, { selector: 'date', fullYear: true, locale: Sys.CultureInfo.CurrentCulture.name }) + this.timelessText;
                }
            } else if (this.datePattern) {
                // If this is a date-only value ("D" date time type), undo the local time conversion before formatting.
                if (this.dateOnly) {
                    d = new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate());
                }
                return d.format(this.datePattern, { locale: Sys.CultureInfo.CurrentCulture.name });
            } else {
                if (this.utc) {
                    var dateOnly = new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate());
                    return locale.format(dateOnly, { selector: 'date', fullYear: true, locale: Sys.CultureInfo.CurrentCulture.name });
                }
                else {
                    return dojo.date.locale.format(d, { selector: 'date', fullYear: true, locale: Sys.CultureInfo.CurrentCulture.name });
                }
            }
        }
    });
});

This function was lifted from the 8.4 version of the Sage.UI.Controls.GridParts.Columns.DateTime widget. Obviously in 8.4 this behavior is fixed.

ABOUT THE AUTHOR

Kris Halsrud

Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.

1 Comment

  1. Today i discovered it is happening with the Date only Control on 8.4.

    You can test it on the Contact’s birthday… on the DB it will add the timezone to seconds instead of adding it to hours.

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) news and product updates!

You have Successfully Subscribed!