copy from inciden task 'close notes' to parent incident worknotes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2025 12:26 AM
Hi All ,
I am trying to copy close notes from incident task (when its close complete) to parent incident record in worknotes.
here is the before update with condition close notes changes business rule is used:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2025 08:13 AM - edited 04-01-2025 08:20 AM
Can you try the below code on incident_task table in before update BR the condition is State change to Closed complete
var lastWorkNote = current.close_notes.toString(); var parentInc = new GlideRecord('incident'); parentInc.addQuery('sys_id', current.incident); parentInc.query(); if (parentInc.next()) { parentInc.work_notes = lastWorkNote; parentInc.update(); }
Please mark this as a solution and helpful if this resolves your query.
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2025 08:48 AM - edited 04-01-2025 08:49 AM
Hi @tushar_ghadage ,
Your approach is fine but just few mistakes.
- var lastWorkNote = current.close_notes.getJournalEntry(-1); /// This is just a string field so you don't have to write getJournalEntry. This is use for journal field like work_notes.
- parentInc.addQuery('sys_id', current.parent_incident); // The field name for incident reference field is incident in incident task task table.
You can just use 5 lines of code.
(function executeRule(current, previous /*null when async*/) {
// Add your code here
var close_info = current.close_notes.toString(); // get the value of close notes
var gr_inc = new GlideRecord("incident");
gr_inc.get("sys_id",current.incident);
gr_inc.work_notes = close_info;
gr_inc.update();
})(current, previous);
If my response helped, please hit the Thumb Icon and accept the solution so that it benefits future readers.
Regards,
Rohit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-02-2025 01:38 AM
Hi @tushar_ghadage ,
Can you tell what's the issue you are facing?
Make sure your BR is in Inicdent_task table and condition should be State Changes to "Closed Complete"
Regards,
Rohit
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-01-2025 09:02 AM
Hi @tushar_ghadage
Try this
(function executeRule(current, previous /*null when async*/ ) {
if (current.getValue('incident')) {
var incGr = current.incident.getRefRecord();
incGr.work_notes = current.getValue('close_notes');
incGr.update();
}
})(current, previous);
Please mark my answer as helpful/correct if it resolves your query.
Regards,
Chaitanya