The Zurich release has arrived! Interested in new features and functionalities? Click here for more

Copy "workaround" from Problem form to related incidents

isaacpio
Giga Contributor

I would like to copy "workaround" notes from my Problem from to any related incidents when the problem status is set to "Closed/Resolved" or "Known Error"

Currently, nothing gets copied when the Problem status is changed and form is saved. I think this might be because, when saving the form, the notes in the "workaround" field get added into the comments/activity stream below work notes (and the workaround field looks blank).

Any suggestions?

I am trying to use an "After Update" business rule with the following script:

updateRelatedIncidents();

function updateRelatedIncidents() {

  var inc = new GlideRecord("incident");

  inc.addActiveQuery();

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

  inc.query();

  while (inc.next()) {

      if (inc.incident_state == 3)

            inc.incident_state = 2;

      if (!current.work_around.nil())

            inc.work_notes = "Related problem " + current.number + " closed with the following Workaround:\n\n" + current.work_around;

      inc.update();

  }

}

Thank you!

Cheers,

Isaac

1 ACCEPTED SOLUTION

Goran WitchDoc
ServiceNow Employee
ServiceNow Employee

I think the reason is that work_around is a journal entry. So it's empty when you tries to take data from it. Look below at the "communicate workaround" ui action. I think you taken most of it.. but as you can see it has the "getJournalEntry(1) on the end which means it takes the last entry in the journal.



Let me know if you get stuck.



//Göran




current.update();


workaround();




function workaround(){


      var num = current.number;


      var incident = new GlideRecord("incident");


      incident.addQuery("problem_id", "=", current.sys_id);


      incident.addQuery("incident_state", "<", 6);


      incident.query();


      while (incident.next()) {


              incident.comments = (num + ' ' + current.work_around.getJournalEntry(1));


              incident.update();


      }


      gs.addInfoMessage('Workaround communicated');


      action.setRedirectURL(current);


}


View solution in original post

5 REPLIES 5

Glad to help out