How to update worknotes Based on Related List Records adding/removing?

siva44
Tera Contributor

Hi,

I have one requirement update the work notes whenever records added or removed in related list like  service now  incident table whenever under related list  problem record added then work notes updated with "

Problem PRB0000001 'Parent' field added " this is the OOB how to configure this
5 REPLIES 5

Barath P
Tera Guru

Hi @siva44 ,

Create a Business Rule 

 

(function executeRule(current, previous /*null when inserted*/) {
    var incident = new GlideRecord('incident');
    if (incident.get(current.parent)) {  // Ensure it's linked to an Incident
        var problem = new GlideRecord('problem');
        if (problem.get(current.child)) {  // Ensure it's linked to a Problem
            
            var actionText = current.operation() === 'insert' ? "added" : "removed";
            var workNote = "Problem " + problem.number + " 'Parent' field " + actionText;
            
            incident.work_notes = workNote;
            incident.update();
        }
    }
})(current, previous);

 

 

"If you found my answer helpful, please give it a like and mark it as the accepted solution. It helps others find the solution more easily and supports the community!"

 

Thanks & Regards,

Barath.P

 

siva44
Tera Contributor

Hi @Barath P  Which table we need to create that BR

Barath P
Tera Guru

@siva44 

For a Business Rule (BR) to track when a Problem Record is added or removed in the Related List of an Incident, you should use the task_rel_task table

"If you found my answer helpful, please give it a like and mark it as the accepted solution. It helps others find the solution more easily and supports the community!"

 

Thanks & Regards,

Barath.P

siva44
Tera Contributor

I am not abel to findout the that table in PDI 

siva44_0-1738999233299.png