- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2021 01:52 PM
Hi, I have a requirement where a field is modified in RITM, work notes have to be added in SCTASK with that information.
I have added the following "before" business rule for "insert" and "update" on sc_req_item table
-------
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var list = current.fieldName.getDisplayValue();
current.work_notes = "fieldName has been modified to " + list;
var grTaskList = new GlideRecord("sc_task");
grTaskList.addQuery('request_item', current.sys_id);
grTaskList.query();
while(grTaskList.next()){
grTaskList.worknotes = "fieldName has been modified to 1 \n" + list;
//grTaskList.update(); - added this upon a suggestion from another sample
}
})(current, previous);
but I see the following
the work notes are being added to the top and not in work notes under Activities. Please let me know of any suggestions.
Thank you!
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2021 04:28 PM
Change:
grTaskList.worknotes = "fieldName has been modified to 1 \n" + list;
for:
grTaskList.work_notes.setJournalEntry("fieldName has been modified to 1 \n" + list);
Please mark as accepted solution if correct
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2021 02:46 PM
This is really hard to follow what is happening/not happening with such a limited area on the screen shot and all of the redacting - can't you mock up some data that doesn't require obfuscation? A before Business Rule running on the sc_req_item will need the grTaskList.update(); line or else the sc_task field changes will not take effect - unless you have another client script or business rule that is affecting this update. Your current.work_notes line doesn't make sense unless you also intend to update the RITM with a work note. So with the update() line added, what is it that you see on catalog task(s) when a field is modified on the RITM? I'm not following what 'added to the top' means. On your form layout for sc_task, which is the partial form I assume is shown, what is it that you have just before the Work notes field?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-10-2021 04:28 PM
Change:
grTaskList.worknotes = "fieldName has been modified to 1 \n" + list;
for:
grTaskList.work_notes.setJournalEntry("fieldName has been modified to 1 \n" + list);
Please mark as accepted solution if correct
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-11-2021 08:32 AM
Sorry about the incomplete screenshot.
Combination of uncommenting grTaskList.update();
and
grTaskList.work_notes.setJournalEntry("fieldName has been modified to 1 \n" + list);
worked and shows the update in work notes but I am still seeing the update also displaying on the top as well. So, there are duplicate entries for the same in two places. Is there anyway for the update not to show up on the top or is this working as designed? Appreciate it.