28 views

Description

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");
gr.get("<sys_id>");

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


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.
Note that the "Resolved at" field is not populated.

Workaround

To avoid this issue either don't 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;
gr.update();

Related Problem: PRB1270618

Seen In

There is no data to report.

Associated Community Threads

There is no data to report.

Article Information

Last Updated:2018-07-26 21:55:12
Published:2018-07-27