- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2017 10:33 AM
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:
- Mapping the source field to the target field of target.work_notes
- 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:
- target.work_notes.setValue(CI);
- 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.
Solved! Go to Solution.
- Labels:
-
Scripting and Coding
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2017 11:51 AM
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();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2017 11:06 AM
Silly question, but just to rule it out, I assume "target" does, indeed, have a work_notes field with a type of journal_input?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2017 11:10 AM
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+'';
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2017 11:19 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2017 11:51 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎11-27-2017 11:51 AM
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();