Add a CI to an Incident
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2024 08:30 AM
Hello everyone, I have created several business rules based on this one to meet the requirements (when an Aloha Incident occurs. Assigned to field changes, the new value must be established in all affected CIs) but none of the ones I have worked correctly for me. created; I would appreciate your help, thanks in advance and greetings.
(function executeRule(current, previous /* null when asynchronous */ ) {
var assignedToAloha = current.task.assigned_to;
var ci = current.ci_item.getRefRecord();
if (ci.isValidRecord()) {
ci.assigned_to = assignedAAloha;
ci.update();
}
})(previous current);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2024 08:39 AM
Hi @Tomas Linde
Have you seen the bold underlined ones are not same in your code:
(function executeRule(current, previous /* null when asynchronous */ ) {
var assignedToAloha = current.task.assigned_to;
var ci = current.ci_item.getRefRecord();
if (ci.isValidRecord()) {
ci.assigned_to = assignedAAloha;
ci.update();
}
})(previous current);
If my post helped you, please click the accept solution button and hit the thumbs up! Thank you!
Oya
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2024 08:45 AM
Sorry, it's an error when translating the text, the attached business rule does not meet the requirements of the story, since I need it to go through all the 'ci_item' and complete each of the AssingedTo fields of each of them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2024 09:02 AM
Hi @Tomas Linde ,
Can you please try below changes to the code and check if those work?
(function executeRule(current, previous /* null when asynchronous */ ) {
var assignedToAloha = current.getValue('assigned_to');
var ci = current.ci_item.getRefRecord();
if (ci.isValidRecord()) {
ci.setValue('assigned_to',assignedToAloha);
ci.update();
}
})(previous current);
Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Regards,
Pranav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎01-24-2024 11:26 AM
This does not work because this part of the code (var assignedToAloha = current.task.assigned_to;) assigns to the variable the current value of the assigned to the task table which is the intermediate reference table between the two tables.