In the code below I am trying to store the current timestamp into a record when it is updated. I looked for an easier way without success.
My ploy was to put a null value into the dynamicform field. This, I figured, would invoke the DEFAULT CURRENT_TIMESTAMP in the database. My reasoning was that this happened when I created a new record, both the CREATED and MODIFIED columns were set correctly. (The table DDL is below.)
I tried putting just the word null into the Default Value for the MODIFIED field. This was interpreted as a string. I tried that because I saw somewhere that calling setValue(null) reverts a field to its default value.
Is there a way I can get a real *null* value into the datetime field, just like a new record would have?
Your expertise would be appreciated. I need to do this all over.
I bring your attention to the statement: LicenseDetailForm.getItem("MODIFIED").setValue(null);
The context is below, near the end.
My ploy was to put a null value into the dynamicform field. This, I figured, would invoke the DEFAULT CURRENT_TIMESTAMP in the database. My reasoning was that this happened when I created a new record, both the CREATED and MODIFIED columns were set correctly. (The table DDL is below.)
I tried putting just the word null into the Default Value for the MODIFIED field. This was interpreted as a string. I tried that because I saw somewhere that calling setValue(null) reverts a field to its default value.
Is there a way I can get a real *null* value into the datetime field, just like a new record would have?
Your expertise would be appreciated. I need to do this all over.
FormItem.defaultValue [IRW] type:any, defaultValue: null
Value used when no value is provided for this item. Note that whenever this item's value is cleared programmatically (for example via item.setValue(null)), it will be reverted to the defaultValue. Developers should use the DynamicForm.values object if their intention is to provide an initial value for a field in a form rather than a value to use in place of null.
Value used when no value is provided for this item. Note that whenever this item's value is cleared programmatically (for example via item.setValue(null)), it will be reverted to the defaultValue. Developers should use the DynamicForm.values object if their intention is to provide an initial value for a field in a form rather than a value to use in place of null.
The context is below, near the end.
Code:
if (!window.LicenseDetailForm) { var message = "Component ID \"LicenseDetailForm\", target of action \"Clear Values\" does not exist"; isc.Log.logWarn(message); if (isc.designTime) { isc.say(message); } } var d = new Date(); var dt = d.getTime(); var dts = d.toUSShortDateTime(); if (LicenseDetailForm.newLogEntry) { if (LicenseDetailForm.newLogEntry != null) { var logValue = LicenseDetailForm.getValue("DESC"); if (logValue == null) { LicenseDetailForm.setValue("DESC",(dts + ": " + LicenseDetailForm.newLogEntry + ".")); } else { LicenseDetailForm.setValue("DESC",(dts + ": " + LicenseDetailForm.newLogEntry + ".\n" + logValue)); } LicenseDetailForm.newLogEntry = null; } } LicenseDetailForm.getItem("SaveButton").setDisabled(true); LicenseDetailForm.getItem("MODIFIED").setValue(null); LicenseDetailForm.saveData(); LicenseDetailForm.changesPending = false;
Code:
CREATE TABLE License( LicenseID BIGINT GENERATED BY DEFAULT AS IDENTITY (START WITH 101, INCREMENT BY 1), LicenseName VARCHAR(16), Enabled BOOLEAN DEFAULT TRUE, StartDate DATE, ExpireDate DATE, LicenseType VARCHAR(16) NOT NULL, EffectiveDays INT DEFAULT 0, UserCount INT DEFAULT 0, MaximumGB INT DEFAULT 0, PrioritySupport BOOLEAN DEFAULT FALSE, Renewable BOOLEAN DEFAULT TRUE, MonthlyFee FLOAT NOT NULL, QuarterlyFee FLOAT NOT NULL, YearlyFee FLOAT NOT NULL, Desc VARCHAR, Created TIMESTAMP DEFAULT CURRENT_TIMESTAMP, Modified TIMESTAMP DEFAULT CURRENT_TIMESTAMP, CONSTRAINT IDX_LicenseName UNIQUE (LicenseName) );
Comment