Copy work notes from interaction to associated HR Case
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
When creating a new HR case on an interaction, I'm trying to get the work notes from the interaction to copy over to the new HR Case that's associated. I'm trying to create a business rule but not having luck. Can anyone help?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
Hi @tworzala , hope your doing well!
Found this article that could help you!
Solved: How to copy worknotes from interaction to Incident... - ServiceNow Community
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
an hour ago
@tworzala Can you please share script you have in your BR.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
36m ago
Here's the latest script I was trying. The BR is on the HR case after insert.
(function executeRule(current, previous /*null when async*/) {
// Find any interactions linked to this HR Case via interaction_related
var irGR = new GlideRecord('interaction_related');
irGR.addQuery('related_record', current.sys_id); // HR case is the related record
irGR.addQuery('parent.table', 'interaction'); // Ensure parent is an interaction
irGR.query();
var notesToAdd = '';
while (irGR.next()) {
var interaction = new GlideRecord('interaction');
if (interaction.get(irGR.parent.sys_id)) {
if (interaction.work_notes) {
// Append each interaction's notes with separator
notesToAdd += (notesToAdd ? '\n' : '') + interaction.work_notes;
}
}
}
// Only update the HR case if there are notes to add
if (notesToAdd) {
var existing = current.work_notes || '';
current.work_notes = existing ? existing + '\n' + notesToAdd : notesToAdd;
current.update(); // safe to update because this is After Insert
}
})(current, previous);
