Calling setDateNumericValue"with the same value twice on a GlideElement that supports it marks the field as unchanged and the element is not updated


Calling the setDateNumericValue method twice with the same value on a GlideElement that supports this method (for example, a GlideDateTime field) will mark that field as unchanged and on calling insert or update the value in the field will not be saved.

Steps to Reproduce


1. Open an existing Incident record.
2. Copy the record's sys_id and then click on the Resolution information tab.
3. In a separate tab, run the following code as a background, replacing <sys_id> with the one from the Incident record.

var gr = new GlideRecord("incident");

var gdt = new GlideDateTime("2018-01-01 12:34:56");
// gr.resolved_at.setDateNumericValue(gdt.getNumericValue());

4. Go back to the open Incident form and confirm that the Resolved at field now contains "2018-01-01 12:34:56".
5. Clear the Resolved at field and save the Incident.
6. Repeat step 3 but uncomment the extra call to setDateNumericValue before running the script.
7. Check the Incident form again. Notice the "Resolved at" field is not populated.


After carefully considering the severity and frequency of the issue, and the cost and risk of attempting a fix, it has been decided to not address this issue in any current or near future releases. We do not make these decisions lightly, and we apologize for any inconvenience.

To avoid this issue, either do not update the field with the same value multiple times (put a test in the script making the call), or use the following code as a workaround:

var gdt = new GlideDateTime("2018-01-01 12:34:56");
gr.resolved_at = gdt;
gr.resolved_at = gdt;


Related Problem: PRB1270618