Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Add a CI to an Incident

Tomas Linde
Tera Expert

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);

5 REPLIES 5

I need to correctly go through the CIs associated with that table like this:

 

(function executeRule(current, previous /* null when async */) {

var assignedToAloha = current.task.assigned_to;

var taskCiRecords = new GlideRecord('task_ci');
taskCiRecords.addQuery('task', current.task.sys_id);
taskCiRecords.query();

while (taskCiRecords.next()) {
taskCiRecords.assigned_to = assignedToAloha;
taskCiRecords.update();
}

})(current, previous);
 
or this mode

(function executeRule(current, previous /* null when async */ ) {

var assignedToAloha = current.task.assigned_to;
var ciTableName = current.ci_item.getRefTable();

var ciRecords = new GlideRecord(ciTableName);
ciRecords.addQuery('task', current.task.sys_id);
ciRecords.query();

while (ciRecords.next()) {
ciRecords.assigned_to = assignedToAloha;
ciRecords.update();
}

})(current, previous);