- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2016 06:49 PM
I would like to copy "workaround" notes from my Problem from to any related incidents when the problem status is set to "Closed/Resolved" or "Known Error"
Currently, nothing gets copied when the Problem status is changed and form is saved. I think this might be because, when saving the form, the notes in the "workaround" field get added into the comments/activity stream below work notes (and the workaround field looks blank).
Any suggestions?
I am trying to use an "After Update" business rule with the following script:
updateRelatedIncidents();
function updateRelatedIncidents() {
var inc = new GlideRecord("incident");
inc.addActiveQuery();
inc.addQuery("problem_id", current.sys_id);
inc.query();
while (inc.next()) {
if (inc.incident_state == 3)
inc.incident_state = 2;
if (!current.work_around.nil())
inc.work_notes = "Related problem " + current.number + " closed with the following Workaround:\n\n" + current.work_around;
inc.update();
}
}
Thank you!
Cheers,
Isaac
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2016 10:49 PM
I think the reason is that work_around is a journal entry. So it's empty when you tries to take data from it. Look below at the "communicate workaround" ui action. I think you taken most of it.. but as you can see it has the "getJournalEntry(1) on the end which means it takes the last entry in the journal.
Let me know if you get stuck.
//Göran
current.update();
workaround();
function workaround(){
var num = current.number;
var incident = new GlideRecord("incident");
incident.addQuery("problem_id", "=", current.sys_id);
incident.addQuery("incident_state", "<", 6);
incident.query();
while (incident.next()) {
incident.comments = (num + ' ' + current.work_around.getJournalEntry(1));
incident.update();
}
gs.addInfoMessage('Workaround communicated');
action.setRedirectURL(current);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2016 10:49 PM
I think the reason is that work_around is a journal entry. So it's empty when you tries to take data from it. Look below at the "communicate workaround" ui action. I think you taken most of it.. but as you can see it has the "getJournalEntry(1) on the end which means it takes the last entry in the journal.
Let me know if you get stuck.
//Göran
current.update();
workaround();
function workaround(){
var num = current.number;
var incident = new GlideRecord("incident");
incident.addQuery("problem_id", "=", current.sys_id);
incident.addQuery("incident_state", "<", 6);
incident.query();
while (incident.next()) {
incident.comments = (num + ' ' + current.work_around.getJournalEntry(1));
incident.update();
}
gs.addInfoMessage('Workaround communicated');
action.setRedirectURL(current);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-26-2017 11:17 PM
Hi goran,
could you please help me, how to do this in scoped application.
Thanks,
Rajashekhar Mushke
Rising star : 2022 - 2024
Community Leader -2018
Connect me on LinkedIn : Rajashekhar Mushke

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2016 12:50 PM
Hi Isaac,
The field "work_around" is a Journal Input field... which means it's for entry only. So it may be that once your Problem record has been saved, it no longer holds a value in that field.
I would suggest you try changing your BR to run Before instead of After updates, I think 'work_around' would still hold the value entered as the work around at this point.
You could also enter some "gs.log('some message here);" statements in your code temporarily to see which conditions are firing.
-Brian
Edit: @Goran... I really need to refresh the page more often.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-25-2016 12:54 PM
Thanks for your responses wwar1ace and goranlundqvist. Understanding that the Workaround is a journal entry was key to making the copy work. You're script was really heplful too Goran.
Cheers!