- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2023 10:02 AM
if user updates worknotes of problem task then worknotes of incident should get updated using bsuiness rule
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2023 11:20 AM
@Priti18 You can achieve this functionality by creating an onBefore Update business rule on Problem Task table as follows.
Here is the script for the business rule.
(function executeRule(current, previous /*null when async*/ ) {
// Add your code here
if (current.problem) {
var incidentRec = new GlideRecord('incident');
incidentRec.addQuery('problem_id',current.problem);
incidentRec.query();
while(incidentRec.next()){
incidentRec.work_notes = current.work_notes.getJournalEntry(1);
incidentRec.update();
}
}
})(current, previous);
Please mark this answer helpful and correct if it addresses your requirement.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-25-2023 11:24 AM - edited ‎04-25-2023 11:25 AM
Hi,
To update the worknotes of an incident when a worknote is added to a problem task, you can create a business rule with the following settings:
Table: Problem Task [problem_task]
When: After [Insert, Update]
Filter conditions:
- Condition 1: Current [work_notes] is not empty
- Condition 2: Previous [work_notes] is not equal to current [work_notes]
Note: The filter conditions above will ensure that the business rule is only triggered when the work_notes field is updated.
Script:
// Get the current problem task var currentTask = current;
// Get the associated incident var incident = new GlideRecord('incident');
incident.addQuery('number', currentTask.problem_id.number);
incident.query();
// Update the work notes of the incident
if (incident.next()) {
incident.work_notes = currentTask.work_notes;
incident.update();
}
The script above gets the current problem task and finds the associated incident using the problem_id field. It then updates the work_notes field of the incident with the value of the work_notes field of the problem task.
Make sure to test the business rule thoroughly in a non-production environment before deploying it to production.
Thanks,
Rahul Kumar
Thanks,
Rahul Kumar