How to import work notes / comments to incidents when migrating from another program

David Morden
Mega Expert

I'm working on a client migration from ManageEngine ServiceDesk Plus to the ServiceNow platform (Istanbul).   I have been able to import all the incidents from ME SDP through import sets and transform maps.   When I use the transform maps to import the work notes and comments from the old system, all new comments are tagged with my user and time/date of the import.   Scavenging through other postings surrounding this same topic, I have not found anything with a successful outcome.   I have tried importing the comments to both the sys_audit and the sys_journal_field tables (tried individually and importing to both), but nothing shows in the UI and the created date and created by fields are overwritten with my user and the import date/time.

Can anyone help to resolve this issue?   The client needs this information available with the original info as they are a legal establishment.

10 REPLIES 10

Jon Barnes
Kilo Sage

sys_journal_field is the correct place to import those. Using autoSysFields(false) on gliderecord should get you what you need as far as setting your own values for sys_created_on and sys_created_by. Here is a sample script that inserts a record into sys_journal_field and sets my own created fields:



var gr = new GlideRecord('sys_journal_field');


gr.autoSysFields(false);


gr.newRecord();


gr.sys_created_by = 'test.user';


gr.sys_created_on = new GlideDateTime('2017-04-01 02:30');


gr.element = 'comments';


gr.name = 'task';


gr.element_id = '53f367e20f123200e23909bce1050e27';


gr.value = 'This is a test journal entry';


gr.insert();



In your case, if you are doing this in an import, then an onbefore transform script should be all you need where you would do this: target.autoSysFields(false)


and then map your sys_created_on and sys_created_by from the source file. Just keep in mind that if you do this in a transform map, you need to probably put the sys_ids of the incidents in your excel file because it won't be able to look it up by incident number. Or you can write into your onBefore script to lookup the sys_id by incident number and put that in the target record.



Notice that I put the name field above as "task". this is because that is where comments and work_notes reside. so make sure you set "task" for the name field and not "incident"



Then, for getting it to display in the activity feed, we need to refresh the history, try this in an onAfter transform script. I tested it on my istanbul instance, but should work on Geneva as well:



var ghs = new GlideHistorySet(target);


ghs.refresh();



Let me know how that comes along. I tested the above GlideHistorySet part and it is not showing the proper date and user there, though the journal field table does have it correct. I will see if I can figure out how to get that history updated properly.


I have tried inserting the 2 scripts as outlined above (see pics below), but they continually import with the "System Administrator" name association and the time/date they were imported.   I have even gone as far as to remove the journal and journal_input from the glide.import_template.field_types_to_ignore list.



So far no joy.



Conversation Field Maps.png


Conversation OnBefore.png


Conversation OnAfter.png


Converation in Incident.png


***For reference, the date on this particular comment was supposed to be 11/28/2016 @ 11:34


When I tested this in my instance, they were actually getting into sys_journal_field correctly with the right sys_created_on and sys_created_by. I believe the issue at this point has to do with the sys_audit table. When the history records are refreshed, they seem to do this based on the audit table as well, and I don't know the exact combination to get those audit records right, but I believe an insert has to be done on sys_audit as well. I think that is the final missing piece.



Can you confirm if the records show the correct sys_created_on and sys_created_by in your sys_journal_field table?


They do not. I checked and they all show the created date/time of the import and created by Sys admin.