- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2025 04:47 AM
I have written a business rule on sc_req_item i.e after insert here is the code
In this i am not getting record by doing grp.getRowCount() in system log i am getting record as 0.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2025 05:07 AM - edited 05-18-2025 05:45 AM
Hi @sanasayyad,
Here is the revised code. It should be after update.
Try this. Your code has few misses. Updated them below.
(function executeRule(current, previous /*null when async*/) {
var sys_id = current.getUniqueValue();
var scTask = new GlideRecord('sc_task');
scTask.addActiveQuery();
scTask.addQuery('request_item', sys_id);
scTask.query();
if(scTask.hasNext()){
var currentWorkNotes = current.work_notes.getJournalEntry(1);
while(scTask.next()){
if(scTask.work_notes.getJournalEntry(1) == '' || currentWorkNotes.indexOf(scTask.work_notes.getJournalEntry(1)) <0){
scTask.work_notes = currentWorkNotes;
scTask.update();
}
}
}
})(current, previous);
Let me know if this worked.
Regards,
Vikas K
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-18-2025 05:07 AM - edited 05-18-2025 05:45 AM
Hi @sanasayyad,
Here is the revised code. It should be after update.
Try this. Your code has few misses. Updated them below.
(function executeRule(current, previous /*null when async*/) {
var sys_id = current.getUniqueValue();
var scTask = new GlideRecord('sc_task');
scTask.addActiveQuery();
scTask.addQuery('request_item', sys_id);
scTask.query();
if(scTask.hasNext()){
var currentWorkNotes = current.work_notes.getJournalEntry(1);
while(scTask.next()){
if(scTask.work_notes.getJournalEntry(1) == '' || currentWorkNotes.indexOf(scTask.work_notes.getJournalEntry(1)) <0){
scTask.work_notes = currentWorkNotes;
scTask.update();
}
}
}
})(current, previous);
Let me know if this worked.
Regards,
Vikas K