The CreatorCon Call for Content is officially open! Get started here.

problem workaround field

johnrob18
Giga Guru

I have taken Problem OOB. When I type in the workaround field on the problem record does not seem to hold the data , once I have saved the record, the contents disappears - there ia an entry on the audit trail but cannot see any thing in the field.

How does the 'cascade worksround' function work - again this does not seem to do anything?

1 ACCEPTED SOLUTION

It's slightly different based on the field type.   This code has both ways.   You can just un-comment whichever one you want to use.



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)); //Communicate last entry from journal field


              incident.comments = (num + ' ' + current.work_around); //Communicate from standard string field


              incident.update();


      }


      gs.addInfoMessage('Workaround communicated');


      action.setRedirectURL(current);


}


View solution in original post

5 REPLIES 5

Mark Stanger
Giga Sage

What you're seeing is actually a feature of 'journal' type fields.   It allows you to record multiple pieces of input over time rather than a single, static block of text.   It works in the same way as the 'Additional comments' and 'Work notes' field on the incident form.   Check this article out for more information.



Using Journal Fields - ServiceNow Wiki



I have seen some customers personalize the dictionary for the 'Workaround' field and change it to a 'String' type instead so that it works like a regular string field.   There's no harm in doing that and you could even change it back to a journal field in the future if you wanted because both types are just strings at the DB level.


I cant seem to get this communicate workaround to work.


I have redefined the workaround filed to be a string (actuall I have tried with a journal as well) and I can t get it to work as ideas?



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.u.work_around = (num + ' ' + current.work_around.getJournalEntry(1));
//               incident.u_work_around = me.u_work_around;
              incident.update();
      }
      gs.addInfoMessage('Workaround communicated');
      action.setRedirectURL(current);
}


It's slightly different based on the field type.   This code has both ways.   You can just un-comment whichever one you want to use.



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)); //Communicate last entry from journal field


              incident.comments = (num + ' ' + current.work_around); //Communicate from standard string field


              incident.update();


      }


      gs.addInfoMessage('Workaround communicated');


      action.setRedirectURL(current);


}


This seems to be working but there is no text in the comments field on the Incident just the PR number in the activuty log (see below).


There is text in the current.work.around field and it has been saved



acr.PNG