- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2024 10:42 AM - edited ‎01-04-2024 10:44 AM
The logging statements in my script confirm the retrieval of the associated 'wm_task' record and the identification of the value for 'current.close_notes'. Despite these verifications, the transfer of 'current.close_notes' string value into 'gr.work_notes' doesn't seem to occur as intended. I'm seeking advice on whether there's a more effective method to facilitate this transfer within the context of an After Update Business Rule.
(function executeRule(current, previous /*null when async*/) {
var currentSysId = current.sys_id; // Get the sys_id of the current record
var gr = new GlideRecord('wm_task');
gr.addQuery('cloned_from', currentSysId); // Query for wm_task records where cloned_from matches the current sys_id
gr.query();
if (gr.next()) {
// Access the related wm_task record with the same sys_id in cloned_from field
gs.info('Related wm_task record found: ' + gr.getValue('number'));
// You can perform actions on the related record here
// Check if the close_notes field has a value before copying it to work_notes
if (current.close_notes) {
gs.info('Value of close_notes field: ' + current.close_notes);
// Copy close_notes from the current record to work_notes of the found record
gr.work_notes = current.close_notes;
// Update the found record to save the changes
gr.update();
} else {
gs.info('close_notes field is empty.');
// Handle accordingly if close_notes is empty
}
}
})(current, previous);
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2024 10:54 AM
It should work. Can you try with below script?
Also is it entering the script when you save the ticket?
gr.work_notes = current.getValue('close_notes');
Please mark this response as correct or helpful if it assisted you with your question.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2024 10:54 AM
It should work. Can you try with below script?
Also is it entering the script when you save the ticket?
gr.work_notes = current.getValue('close_notes');
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-04-2024 11:14 AM
Thank you @SanjivMeher!
getValue was the solution!