ERROR: client-side validation method: (intermediate value).format is not a function

I can't figure this out. I simply want a ... ceiling on a calendar input value. I'm a JS expert and this is unreal. What is happening to this? I can take the same passed value and do the same operation in Chrome dev tools and it works perfectly as expected.
What is Innovator doing here? It logs the inputTime, as a number, and I can take the same value and pass it to the same formatting function outside of this onChange listener function.

/*

@description: Date must be <= today

@params: this [form element]

*/

// Clean clone of value prop, disconnecting any reference.

// const value = JSON.parse(JSON.stringify(this.value));

console.log('BL_NotTomorrow');

const inn = new Innovator();

const fieldMap = {

    pr_found_date: 'Problem Report found date',

    created_on: 'Opened Date'

};

const {valuename} = this;

console.log('name/value: 'namevalue);

const inputTime = new Date(value).getTime();

console.log(typeof inputTimeinputTime);

const now = Date.now();

let formattederror;

try {

    // FIXME: sees error TypeError: (intermediate value).format is not a function

    /*

    Yet in dev tools with simple expression that should match the following we have no problems:

    new Date(1595221200000).format('MM/dd/yyyy')

    "07/20/2020"

    */

    formatted = new Date(inputTime).format('MM/dd/yyyy');

    console.log("END TRY");

}catch (e) {

    error = e.name + ': ' + e.message;

}

console.log('formatted, inputTime, now: 'formattedinputTimenow);

console.log(error ? 'sees error':'does not see error'error); // sees error every time.

if (error) {

    this.value = '';

    return aras.AlertError(inn.newError(`ERROR > ${error}`));

else {

    this.value = formatted;

    return (inputTime > now) ? inn.newError(`Value of ${fieldMap[name] || 'calendar'} must be in the past.`) : this;

}
^^^^^End code, but you wouldn't know because this editor is as unfriendly as the code editor. Who wants to tab from the title to the print button!? Why would you have tabIndexes on your main form inputs like 128 and 256!? Everything about this thing takes extra time. Goodness gracious. Aras Innovator is going to kill me.

  • Hi Neil,

    I guess the support of .format was dropped in Innovator 12. As far as I know .format is not a native JavaScript function in Data.prototype.

    I took a quick look and checked how Aras deals with dates, e.g. in the Method ES_ReindexAll. In 11SP15 .format still was used, but the code line does not seem to work at all. In 12SP3 a new version showed up that does not use .format. A clear hint that something went wrong in the past.

    You could use var mydate = new Date().toLocaleDateString("en-US")); or DateTimeFormat.

  • Angela,

    You're very awesome! Thank you. It ends up my effort to zero-pad months and days from the value of the dojo dijit calendar is fruitless anyway.

    I ended up doing a split and padStart(2, '0') on the month and day portion of the day and then rejoining. BUT, what I really want is to provide the calendar with a format to use on its value. I really need to figure out how to use the various properties/settings on all these dojo widgets within the context of Aras Innovator.

    Thank you very much for being awesome and taking a look at this issue. I wonder if Aras knows that the old code is broken?

    Anyway, good day,

    Neil