Copy work notes from Change to task
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2017 08:07 AM
I community,
I am trying to do something without changing the workflow. I'm trying to copy the work notes from the change to one specific task when it opens.
I have a BR to copy the work notes from the task to parent that is working fine. Now what I'm trying to do is get the work notes or at least the last work note to the task the opens after the first one.
I did this, but it doesn't seem to work, also, it takes a lot of time processing, which is another clue for something being done incorrectly.
Business Rule:
OnBefore
(function executeRule(current, previous /*null when async*/) {
//var dmn = current.getRefRecord();
var entry = current.work_notes.getJournalEntry(1);
// break the textblock into an array of lines
var lines = entry.split('\n');
lines.splice(0,1);
// join the array back into a single string
var notes = lines.join('\n');
var task = new GlideRecord('service_task');
task.addQuery('change_request',current.sys_id);
task.addQuery('short_description', 'DOES NOT CONTAIN', 'BRD');
task.query();
while(task.next()){
task.work_notes.setJournalEntry("Notes from Demand " + current.number + ": \n" + notes );
task.update();
}
})(current, previous);
Can anyone give some ideas how I can set this up?
Thank you in advance
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2017 08:22 AM
Hi Hugo,
The best way of doing it is to add script after the task is generated in the WF.
Thanks,
Arindam
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-03-2017 08:33 AM
Yes, but as I said, I cannot do that. This is used for just for an Integration.