Not able to set a value to a date field in fix script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 06:37 AM
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();
}
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 06:42 AM
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();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 06:57 AM
Hi,
script looks fine.
Did the query run fine?
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-24-2022 07:02 AM
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();
}