I want to add 'comments' to a transform map without it overwriting anything in there already. is this possible?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2014 02:20 AM
I want to add 'comments' to a transform map without it overwriting anything in there already. is this possible?
Would anyone be able to suggest a javascript fix?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-05-2014 08:34 AM
What table are you importing to? The most commonly used "comments" field, in my experience, is the Task field which is inherited by Incident/Problem/Change. That is a journal field, so anything you import would just create a new entry. If you're talking about another field (ie comments on cmdb_ci) then that is a probably a string field. In that case, I usually write a script along these lines:
var comment = source.u_comment;
target.comments += "\n" + comment;
It's been a while since I've done that, but I double checked it using a background script and it added the new line and 2nd comment I wanted without erasing the original.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2014 01:55 AM
Hi,
Thanks for the response, apologies for not being more specific. Yes it is a config table for Mobile Account. I tested the Transform Script as advised but it just overwrote the comments field. I believe the comments field is called 'comments' rather than 'comment' so i changed it and it still overwrites.
var comments = source.u_comments;
target.comments += "\n" + comments;
Please excuse my ignorance, i'm new to scripting, any ideas what i'm doing wrong?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2014 06:51 AM
Not sure what went wrong. I just tried a test import set on a Demo instance and that script did exactly what I thought it would do.
You're more than welcome to poke around at it if you want:https://notifyusa.service-now.com/nav_to.do?uri=sys_data_source.do?sys_id=ccb1f0ac3d361100eb164534ba...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-06-2014 07:48 AM
Sorry, my fault i was adding the script to 'Transform Scripts' not on the actual field comments.
I do now have to working....However i need to put the script in 'Use Source Script' under 'Fields Maps > Comments'
AND on the transform map itself under Scripts. It doesn't work with one or the other only BOTH.
It was my understanding it would only need to be under 'Use Source Script' on the Field Comments.
Regardless, i do have it working but if you could shine any light on why it may be working this way it would be appreciated.
Thanks in advance.