Copy Additional comments from RITM to SCTASK
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2022 04:39 AM
Hello All!
I used solution from https://www.servicenow.com/community/it-service-management-forum/copy-comments-from-ritm-to-catalog-... because I need to copy additional comments from RITM to active SCTASK/SCTASKs ans it is working but not fully as I expected
So from the beginning:
I have a business rule which copy additional comments from SCTASK to RITM and it is working good:
When to run: Before Insert Update; Condition: Additional comments changes, Parent Release is not empty
Script:
(function executeRule(current, previous /*null when async*/ ) {
/* var gr_parent = new GlideRecord('sc_req_item');
if (gr_parent.get(current.parent))
{
gr_parent.comments = current.comments;
gr_parent.update();
}
*/
var gr_parent = new GlideRecord('sc_req_item');
if (gr_parent.get(current.parent)) {
gr_parent.comments = current.comments;
gr_parent.update();
}
})(current, previous);
And the second Business rule is to copy Additional comment from RITM to active SCTASK:
When to run: After Insert Update; COndition: Additional comments changes
Script:
(function executeRule(current, previous /*null when async*/ ) {
var sctask = new GlideRecord('sc_task');
sctask.addQuery('request_item', current.sys_id);
sctask.query();
while (sctask.next()) {
sctask.comments = current.comments.getJournalEntry(1);
sctask.update();
}
})(current, previous);
So currently when I add the comment to RITM it looks as below:
In SCTASK as below:
May I ask you for help?
I need to change the second business rule (copy add com from RITM to SCTASK) to work as the first one.,
I also need a condition to check if this copied additional comment from RITM is NOT from the same user as from field 'Assigned to' from SCTASK form.
How can I achieve this?
Thanks in advance for help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-01-2022 06:25 AM
@Kasia5 In the second business rule you are updating the comments on SCTASK that intern triggers the first business rule. So to avoid that change the second business rule as follows:
(function executeRule(current, previous /*null when async*/ ) {
var sctask = new GlideRecord('sc_task');
sctask.addQuery('request_item', current.sys_id);
sctask.query();
while (sctask.next()) {
sctask.comments = current.comments.getJournalEntry(1);
sctask.setWorkflow(false);
sctask.update();
}
})(current, previous);
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023