Not able to set a value to a date field in fix script

ASHA22
Kilo Contributor

we have a know issue table , I need to write a fix script to update all the article "start date" field to update to a "Dec 31, 2100".

So i have written fix script like below.

But its not working. I am new to scripting.

Can you please hel me on this

var gr = new GlideRecord("known_issue");
gr.addQuery('number', 'KB0067117');
gr.query();
while (gr.next()) {
    gr.setValue("start_date", "2100-12-31");
    gr.update();
}

3 REPLIES 3

Harshad Wagh
Tera Guru

try following

 

var gr = new GlideRecord("known_issue");
gr.addQuery('number', 'KB0067117');
gr.query();
while (gr.next()) {
    gr.setValue("start_date", new GlideDate("2100-12-31"));
    gr.update();
}

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

script looks fine.

Did the query run fine?

Regards
Ankur

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

Ian Mildon
Tera Guru

Try it like this:

var gr = new GlideRecord("known_issue");
gr.addQuery('number', 'KB0067117');
gr.query();
while (gr.next()) {
    gr.start_date = "2100-12-31";
    gr.update();
}