Can we overwrite the system fields (created by, created date, updated by, etc) with the input value from transform map
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2016 03:18 AM
I am bulk importing historical Incidents. As per the client requires the created date should be back dated to the original date provided in the excel. However even though I mapped the fields properly, the created by and created date is taken as the user who is doing the action. I was able to map system fields and update via tranform map in User table. Only for incident table it doesn't seems to work? Has anybody faced this issue before ?
Regards
Uday
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2016 07:17 AM
You learn something every day. Didn't know there were transform maps. Then, it would probably be more efficient to do an onBefore Transform Script that prevents the script from overwriting the fields to begin with, instead of writing to them twice:
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
target.autoSysFields(false);
})(source, map, log, target);
If that works, because I haven't tried it before.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-14-2016 06:08 AM
amazing trick!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-12-2016 06:19 PM
Hello,
Edit: I have found and confirmed a very simple solution that is scalable:
I have confirmed that you can update system fields such as sys_updated_by and most other sys_ fields using a Transform Map with minimal Script. My instance is currently a Fuji release.
1. Create your Transform Map like normal with your source table, target table, and all of your fields mapped like normal.
2. Check the "Run business rules" box so that it remains unchecked.
3. Check the "Run script" box so that it remains checked.
4. In the script box make sure to add:
//Make sure update is only done on existing records
if ( action == "insert") {
ignore = true;
}
/* Disable SN from auto updating sys_fields*/
//Needed in order to leave historical information unchanged
target.autoSysFields(false);
//Disable the running of business rules that might normally be triggered by SN.
target.setWorkflow(false);
5. At the bottom left, in the Field Maps tab/list, create a new field map
Create a new mapping from your target import table to your sys_ field that you want to update
6. Save, upload your data, and run your transform.
Hope that helps someone out there! I believe this is the correct answer, could you please mark this post as the solution? Thanks!
You can also find a method using Glide Records here: https://community.servicenow.com/thread/162539

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-31-2016 01:05 PM
Would this also apply to Journal fields, or can something be added to the script for that as well? I have a similar issue where I will be needing to import 1000s if not 10's of thousands of historical records from SharePoint into SN so that we can keep a single source of record going forward (not to mention superior search and re. porting).
I've created transform maps and using Excel import to bring in the first set of 2300 records. Most things work ok, but the fields Additional Comments, Work Notes, Created, Active, and Closed. I also noticed that it will always show in the activity feed the account doing the import (not a huge deal, but would like them all to show a specific account that isn't my admin account).
I'd like to import all of these records in one go, rather than importing, exporting to get the sys_id and coalescing on that field (or another), import/updating again to set some of the fields (like Created) etc. while others are still ignored (Journal fields especially) as well as not setting the Active state properly or setting the Closed date for Completed records.
Any help is greatly appreciated!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-16-2016 02:25 PM
My apologies Marcel, I am not familiar with Journal fields. However, I know in the script you can also run Glide queries and update things on other tables, though that may be taxing on the system with large number of records to update. But that may be a way to do it.
In regards to SN showing the account doing the importing, you may be able to get around that using the target.autoSysFields(false); and target.setWorkflow(false); lines. This should stop the auto reporting, however, I cannot tell you if that is best for you (test in a dev environment). You then should be able to do something like target.updated_by = "Your Name here". Or if thats a reference field, you may need to create a reference to the user in an onBefore() script and then do something like target.updated_by = updatesAccount;
My apologies for not being able to help out mre but I hope that helps!