- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2022 08:18 AM
Hi All,
I have a requirement to copy worknotes from problem to incident and vice versa.
Please help me with this.
Thank you.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-20-2022 12:30 AM
Hi
Please find the updated Business Rules below (these will surely work 😉)
Remark: Make sure both the Business Rules are on Insert and Update + When = Before
Incident:
(function executeRule(current, previous /*null when async*/ ) {
var identifier = '[Comment Sync]';
if (current.work_notes.indexOf(identifier) < 0) {
var getProblems = current.problem_id.getRefRecord();
getProblems.work_notes = identifier + '\n' + current.work_notes;
getProblems.update();
}
})(current, previous);
Problem:
(function executeRule(current, previous /*null when async*/ ) {
var identifier = '[Comment Sync]';
if (current.work_notes.indexOf(identifier) < 0) {
var getIncidents = new GlideRecord('incident');
getIncidents.addQuery('problem_id', current.getValue('sys_id'));
getIncidents.query();
while(getIncidents.next()) {
getIncidents.work_notes = identifier + '\n' + current.work_notes;
getIncidents.update();
}
}
})(current, previous);
Please mark my answer as correct if this solves your issues!
If it helped you in any way then please mark helpful!
Thanks and regards,
Kartik
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-14-2023 11:24 PM
Hi,
tested your code and it works fine, IF the incident does not have any other related records.
When incident has 'change reguest' as related record, every time comment is copied, the script creates empty change ticket and the only thing on the empty record is the worknote that was copied to incident from problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-14-2023 12:25 AM
It's working Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-30-2024 01:36 AM
Hi@Kartik Sethi can you suggest any other approach instead of keeping Identifier, In my use case it was just a sync should happen from Incident to Problem and Vice versa!
Thanks & Regards,
Eswar Chappa