- 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 05:38 PM
Hi @Ana39 To do this you would need to create a After Update BR on child table with
condition: State Changes AND
Worknote Changes
and then below script
Script:
Harish

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 04:10 AM
Hi @Ana39 if my response helped you please accept my Solution or let me know if you still have any issues. Happy to assist
Harish
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 06:50 AM
Hi Harish, I will as soon as it works, it is not working right now 😓

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-06-2024 07:00 AM
Hi @Ana39 can you share what is not working? I may assist to fix the issue
Harish