BR loop when copying comments from task <-> item :no solution found
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-28-2018 06:31 AM
Hello
I need to copy all comments from task to item and vice-versa.
I’ve created 2 business rules to do so one on sc_task and one on sc_req_item.
I’m facing a problem of loop which makes the business rule copy more than one the comments on the task or item.
I’ve read plenty of posts talking about this problem and tested all solutions but none of them worked:
- User gr.setWorkflow(false)
- Compare user logged in with assigned to
- Change business rule on before/ on after
- Something like if (ritmComments.indexOf(comments)<0) {
Can anybody help me ?
On sc_req_item I have
(function executeRule(current, previous /*null when async*/) {
updateTasks();
function updateTasks() {
var sctask = new GlideRecord('sc_task');
sctask.addQuery('request_item', current.sys_id);
sctask.query();
while (sctask.next()) {
sctask.comments = 'Additonal Comment from request item : ' + current.comments;
sctask.update();}
} //endwhile
})(current, previous);
On sc_task I have
(function executeRule(current, previous /*null when async*/) {
var ritmGr = new GlideRecord('sc_req_item');
if (ritmGr.get(current.request_item)) {
ritmGr.comments = 'Additonal Comment from task : ' + current.comments.getJournalEntry(1);
ritmGr.update();
gs.addInfoMessage("Additional comments copied from task to request item"); }
})(current, previous);