Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

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

Hi,

script looks fine.

Did the query run fine?

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  10x 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();
}