Transform Map/Script not writing to 'Work Notes'

dustin_barre
Mega Contributor

Looking for some help on this issue I'm running into. I can't seem to get data to write to the work notes field no transform.

Things I have tried:

  1. Mapping the source field to the target field of target.work_notes
  2. Tried a transform script as both onAfter and onBefore due to me needing to write this per record based on particular conditions. Code snippet below:

//Unmatched CI Behavior

(function runTransformScript(source, map, log, target) {

      var ciLookup = new GlideRecord('cmdb_ci');

                  ciLookup.addQuery('name', '=', source.u_asset_names);

                  ciLookup.query();

                  var CI;

                  if(ciLookup.next()) {

                            //ignore

                  }

                  else {

                            CI = source.u_asset_names;

                            log.info("TEST: CI not found: " + CI); //Works and populates the CI variable

                            target.work_notes = CI;

                            target.u_hig_exception_justification = CI; //Works and populates the field.

                  }

})(source, map, log, target);

Also, to be clear, I have tried the following methods as well:

  1. target.work_notes.setValue(CI);
  2. target.work_notes.setJournalEntry(CI); This seems to break the remaining code as well, as I have the target.u_hig_exception_justification - CI; in there just for testing purposes.

Lastly, the code snippet above is working in its entirety ASIDE FROM the 'target.work_notes = CI;'

Any help would be greatly appreciated on this.

1 ACCEPTED SOLUTION

Okay, so... the following ended up being a working solution.





target.work_notes = CI.toString();



So, your idea of making it a string did work, but I had to do it with .toString();


View solution in original post

9 REPLIES 9

Silly question, but just to rule it out, I assume "target" does, indeed, have a work_notes field with a type of journal_input?


Patrick Schult2
Giga Guru

I know this is a silly question, but are you 100% positive that work_notes is the field name? That's the right field name for Tasks, but you haven't specified which table you are writing into.



Also, try casting CI to string like this:


target.work_notes = CI+'';


Yes sir, the table I'm writing to is sn_vul_vulnerable_item and the field is 'work_notes' from the task table.



Dictionary Info for the field:


Table: task


Field: work_notes


Type: journal_input



Let me try converting it to string like you recommend.


Hi Dustin,



I hope you are checking the activities, instead of work_notes. Because work notes is a journal field, which doesnt store any data. It passes everything to Activity and that field remains blank always.



Please mark this response as correct or helpful if it assisted you with your question.

Okay, so... the following ended up being a working solution.





target.work_notes = CI.toString();



So, your idea of making it a string did work, but I had to do it with .toString();