- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 10:59 AM
Hi there, I am developing a new project in a custom table. I have a child task to the ticket and there is required to add a work note in the parent ticket, every time the child task state changes,
It is only the task state updates that are required to be added as work notes in the activity log of the parent custom ticket.
Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 01:31 PM - edited 03-06-2024 07:36 AM
Hi @Ana39 ,
replace sc_task with child table and sc_req_item with parent table
You can create before update business rule on sc_task table ,
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id', current.getValue('request_item'));
gr.query();
while (gr.next()) {
// gr.work_notes =current.state;
gr.work_notes.setJournalEntry(current.getDisplayValue('state'));
gr.update();
}
})(current, previous);
Updated code:
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id', current.getValue('request_item'));
gr.query();
while (gr.next()) {
// gr.work_notes =current.state;
gr.work_notes.setJournalEntry("SC task "+current.number+" state has been changed to "+"'"+current.getDisplayValue('state')+"'");
gr.update();
}
})(current, previous);
Result: In Ritm Table
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 11:55 AM
Hey @Ana39,
You can write a simple Business Rule for it, e.g.
Script:
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var parentGr = new GlideRecord('sc_req_item');
parentGr.get(current.getValue('request_item'));
parentGr.work_notes = 'Some notes here';
parentGr.update();
})(current, previous);
Hope it helps, cheers
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-05-2024 01:31 PM - edited 03-06-2024 07:36 AM
Hi @Ana39 ,
replace sc_task with child table and sc_req_item with parent table
You can create before update business rule on sc_task table ,
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id', current.getValue('request_item'));
gr.query();
while (gr.next()) {
// gr.work_notes =current.state;
gr.work_notes.setJournalEntry(current.getDisplayValue('state'));
gr.update();
}
})(current, previous);
Updated code:
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
var gr = new GlideRecord('sc_req_item');
gr.addQuery('sys_id', current.getValue('request_item'));
gr.query();
while (gr.next()) {
// gr.work_notes =current.state;
gr.work_notes.setJournalEntry("SC task "+current.number+" state has been changed to "+"'"+current.getDisplayValue('state')+"'");
gr.update();
}
})(current, previous);
Result: In Ritm Table
Please mark this comment as Correct Answer/Helpful if it helped you.
Regards,
Swathi Sarang
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 07:20 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2024 09:49 AM