I want to populate the work notes fields from SCTASK to RITM , need a BR for that.
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-13-2023 09:26 PM
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-15-2023 03:30 AM
Hello @posasaihimahars ,
You can configure a Business Rule on the Catalog Task Table (sc_task), as follow :
Then, in the Advanced Tab add the following script:
(function executeRule(current, previous /*null when async*/ ) {
var regex = new RegExp('\n');
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('sys_id', current.request_item);
ritm.addActiveQuery();
ritm.query();
if (ritm.next()) {
var sctaskWorkNotes = current.work_notes.getJournalEntry(1).trim();
var ritmWorkNotes = ritm.work_notes.getJournalEntry(1).trim();
var i = sctaskWorkNotes.search(regex);
if (i > 0) {
sctaskWorkNotes = sctaskWorkNotes.substring(i + 1, sctaskWorkNotes.length);
}
var c = ritmWorkNotes.search(regex);
if (c > 0) {
ritmWorkNotes = ritmWorkNotes.substring(c + 1, ritmWorkNotes.length);
}
if (ritmWorkNotes.indexOf(sctaskWorkNotes) == -1) {
ritm.work_notes = sctaskWorkNotes;
ritm.update();
}
}
})(current, previous);
If that helps please mark my answer as correct / helpful!
And if further help is needed please let me know
Cheers
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2024 10:47 AM
Thank you Clara,
This has helped me out and works as expected. 👍