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

Shishir Srivast
Mega Sage

Can you please try like:



target.work_notes = source.u_asset_names;


Hi Shishar, I actually had tried that as well, I forgot to add that to my post. This doesn't work either. But, if I were to do target.u_hig_exception_justification = source.u_asset_names; this works with no issues.


athm
Tera Guru

Hi Dustin,



Just a thought -   have you tried with unchecking the 'run business rules' checkbox, just to make sure no business rules are overriding your work notes or something.


Hey Anudeep, I have not. Let me try that and get back to you! Thanks for the suggestion.