Update problem work notes using a fix script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 11:30 AM
Hello, I created a fix script (see below) to update the state and work notes of certain problem records. The fix script is not completely working. The state is getting updated, however there is no update to the work notes after I run the fix script. Can someone help me with this? Thanks...
var grProb = new GlideRecord('problem');
grProb.addEncodedQuery('stateNOT IN101,102,103,104,106,107^;
grProb.query();
while (grProb.next()) {
grProb.state = 107;
grProb.setValue.work_note = "This problem record was closed via a script in STRY0240331 because it was in an improper state which was not allowing it to be closed.";
grProb.update();
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 11:39 AM
Hi @Sharon Williams ,
Please use, grProb.work_notes = "......";
Updated Script:
var grProb = new GlideRecord('problem');
grProb.addEncodedQuery('stateNOT IN101,102,103,104,106,107^;
grProb.query();
while (grProb.next()) {
grProb.state = 107;
grProb.work_notes = "This problem record was closed via a script in STRY0240331 because it was in an improper state which was not allowing it to be closed.";
grProb.update();
}
If my answer has helped with your question, please mark it as correct and helpful
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-16-2023 04:46 AM
Hi Karan. I tried the syntax that you suggested initially and it did not work. Do I have to do some type of insert to update the work note with the new text?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-22-2023 05:07 AM
Thanks Karan. I had to update the code to:
grProb.work_notes.setJournalEntry('This problem record was closed via a script in STRY0240331 because it was in an improper state which was not allowing it to be closed.');
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-15-2023 11:54 AM
Try below
var grProb = new GlideRecord('problem');
grProb.addEncodedQuery('stateNOT IN101,102,103,104,106,107^;
grProb.query();
while (grProb.next()) {
grProb.state = 107;
grProb.setValue("work_notes", "This problem record was closed via a script in STRY0240331 because it was in an improper state which was not allowing it to be closed.");
grProb.update();
}
Please mark my response as correct and helpful if it helped solved your question.
-Thanks