From Problem, the related link "Communicate Workaround" returns an undefined value in the related incidents

stevedag
Kilo Expert

Anybody knows why the link Communicate Workaround in a problem, which is a UI Action that comes Out Of the Box (OOB), returns an "Undefined Value" in the incidents related to this problem instead of populating with the WorkAround field content?

 

According to my undestanding, I should replace current.work_around.getJournalEntry(1) with a variable defined earlier, like num and incident that are defined.   But before I modify it, since it's a OOB Script, maybe there's something I'm missing.   Thanks for your input.

 

Here the content of the OOB script of the UI Action:

 

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

1 ACCEPTED SOLUTION

stevedag
Kilo Expert

OK, with your help, I finally found the solution.   I post it here so it may be used by someone facing a similar issue.



The reason why the script is not working in our environnement and returns a value of "undefined" is because the field work_around has been changed when we installed the Problem Management a few months ago.   It's type has been changed for "STRING" instead of the default type of "JOURNAL INPUT". By doing so, the UI Action "Communicate Workaround" doesn't work because of the following line which tries to copy a journal entry:



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



To fix our problem, I either have to put the field type back to journal input or replace the line by this one:



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



Since the field type has been change to allow the work_around to remain present in the field instead of being removed and copied in the activity logs, I'll change the script to refer to the value of current.work_around and not its journal entry.



Special thanks to Michael, Kalaiarasan and Adam who each gived me a part of the solution.



find_real_file.png


View solution in original post

16 REPLIES 16

I agree it is strange. When I try this on our dev instance I don't even get the "undefined", just a blank entry...


Ok, I did try what Adam posted earlier, and the problem is really related to the current.work_around.getJournalEntry(1) or (-1).   They both return undefined when used.   When I populate with other fields or hard coded text like ABC, it works:   Here's the screenshot :



find_real_file.png


It means the UI_Action can't read the current.work_around field.   I don't know why.



Work_around field is filled up and I've tried saving its content before clicking on the Communicate Workaround Link and clicking without saving.   The work_around field is labeled "Temporary solution".   May this be the reason?   I should use the label instead of the name of the field?


nope... field name has to be used... Can you please try some other field for updating ? just for testing try to use short_description


short_description works.   On my last screenshot, these are the results:



11:57 PRB0010001 Undefined --------------------> result of current.work_around.getJournalEntry(-1)


11:52 PRB0010001 ACF118748: Icare error ---> result of short_description


10:59 PRB0010001 ABC -----------------------------> result of incident.comments = ("ABC");


10:57 PRB0010001 Undefined --------------------> result of current.work_around.getJournalEntry(1)






this should work


current.work_around.getJournalEntry(1)



does work_around field has some value ? and is work_around field active?