- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 02:35 AM
Hello Expert,
When ever the 1st task will generated whatever all comment on ritm would be copy over to task in servicenow with timestamp.
How can archive this
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 03:35 AM
I think you can write before business rule on task table, below is the sample code you can use :
(function executeRule(current, previous /*null when async*/) {
// Check if this is the first task created for the RITM
if (current.number.startsWith('TASK') && current.number.split('.')[1] === '1') {
// Retrieve comments from the RITM
var ritm = new GlideRecord('sc_req_item');
if (ritm.get(current.parent)) {
var ritmComments = ritm.comments.getJournalEntry(-1);
// Copy comments to the task
if (ritmComments) {
current.comments = "Comments from RITM:\n" + ritmComments;
current.update();
}
}
}
})(current, previous);
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 02:58 AM
Hi @Rajveer
Might be helpful
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.
Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]
****************************************************************************************************************
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 03:17 AM
Hi @Rajveer ,
Please check below code
var taskGr = new GlideRecord('sc_task');
taskGr.addQuery('request_item', current.sys_id);
taskGr.query();
if (taskGr.next()) {
taskGr.comments = current.comments;
taskGr.update();
}
}
Please mark my answer correct and helpful if this works for you
Thanks and Regards
Sarthak
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-15-2024 03:35 AM
I think you can write before business rule on task table, below is the sample code you can use :
(function executeRule(current, previous /*null when async*/) {
// Check if this is the first task created for the RITM
if (current.number.startsWith('TASK') && current.number.split('.')[1] === '1') {
// Retrieve comments from the RITM
var ritm = new GlideRecord('sc_req_item');
if (ritm.get(current.parent)) {
var ritmComments = ritm.comments.getJournalEntry(-1);
// Copy comments to the task
if (ritmComments) {
current.comments = "Comments from RITM:\n" + ritmComments;
current.update();
}
}
}
})(current, previous);
Please Mark ✅Correct if this solves your query and also mark 👍Helpful if you find my response worthy based on the impact.
Thanks