Change a work note on update???

DrewW
Mega Sage
Mega Sage

I think I have gone off my rocker again.   I'm trying to do a search and replace when work notes changes and what I get is this

User Enters

Hi there replace this.

System adds to the work notes

Hi there replace {DELETED}.

Hi there replace this.

So how do I clear out a work note?

I know I can just go to the sys_journal_field table and to do this but at this point I want to know if its even possible to dump a work note on update.

Things tried

current.work_notes = "";

current.work_notes = "NULL";

current.setValue("work_notes", "");

All of the above resulted in getting what I entered in the field and also what the value was altered to.

8 REPLIES 8

What does your business rule look like at the moment? Is it a "before" update rule?


Yes its an onBefore rule and this is all it does.



var wn = current.getValue("work_notes");


var matches = wn.match(/\d{7,12}|\d{3}[^0-9!\n]\d\d[^0-9!\n]\d{3,}/gi);


if(matches){


  matches = (new ArrayUtil()).unique(matches);


  for(var i = 0; i < matches.length; i++){


            wn = wn.replace(matches[i], "{DELETED}");


  }


  current.work_notes = wn;


}



But this is what I get


Please remove this {DELETED}.


Please remove this 1234567.


From my limited knowledge, setAbortAction would be the only way to prevent that worknote from being added to the record.


http://wiki.servicenow.com/index.php?title=GlideRecord#setAbortAction


Trouble is, that would abort the whole update, so if other fields are changed at the same time, they would be lost.



IMO, onSubmit client script would be the way to go if possible.


At this point I agree just because a BR that alters a journal field is so screwee.