Update the work note field on the incident form

zubair3
Tera Contributor

Update the work note field on the incident form. When the workaround field is updated on the problem from the update same workaround is on the incident table.

5 REPLIES 5

Pushkar-Snow
Mega Guru

Hi @zubair3 ,

 

If my understanding is correct you want to add work notes when workaround field updated on the problem record.

 

1] There is already OOB UI action available to communicate the workaround to related incident records you can find that in the related link section. Please find below screenshot.

PushkarSnow_1-1676358897843.png

 

2] If you want to achieve this without user interaction and should work automatically. you can write business rule and update the related incident records work-note field.  Please find below screenshot and script you can use to achieve this.

 

PushkarSnow_0-1676358737713.png

 

var incident = new GlideRecord("incident");
  incident.addQuery("problem_id", "=", current.sys_id);
  incident.query();
  while (incident.next()) {
    if ( incident.active == true ){
        incident.work_notes = current.workaround;
        incident.update(); 
    }
  }

 

 

Please ask if you face any problem. 

If I am able to help you with your question, Please click the Thumb Icon and mark as Correct. 

 

Regards,

Pushkar

SatyakiBose
Mega Sage

Hello @zubair3 

Please refer to the community posts below.

The scripts that you can use to acheive this requirement is given below.

  1. Copy Work Notes from Problem to Incident and Vice Versa
  2. How to Copy Problem record Work Notes into Related Incident work notes
  3. Copy Comments from a Problem to all incidents
     
 

Madala Chaitany
Giga Guru

Hi @zubair3 

Try below code

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

var rec = new GlideRecord("incident");
rec.addQuery("problem_id", current.sys_id);
rec.addActiveQuery();
rec.query();
while (rec.next()) {

rec.work_notes = current.work_notes.getJournalEntry(1); 

rec.update();
}
})(current, previous);

 

If you find the solution as helpful, Accept as Solution

Regards,

Chaitanya

SoniaShridhar13
Giga Guru

Hi @zubair3  I once used below script for populating the worknotes of an incident form to its related incident task form worknotes

 

 

After business rule :

condition: current.isValidRecord() &&current.work_notes.changes()

 

script:

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

updateRelatedIncidents();

 

function updateRelatedIncidents() {

var rec = new GlideRecord("problem_task");// Add the table name which needs to copy the work notes

rec.addActiveQueryry();

rec.addQuery("problem_id", current.sys_id);

rec.query();

while (rec.next()) {

 

rec .work_notes =current.work_notes.getJournalEntry(1);

 

rec .update();

}

}

 

 

})(current, previous);

Please mark it helpfu if it helps...

 

Thanks,

Sonia