data migration from domain A to domain B
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
yesterday
we are moving from the security incident table to the custom security table which is same as security incident table. we have 17 client which are domain separated, and security table is in the domain A and custom security table is in domain for this data migration we using export the data from the list view and importing using load data (import set table and transform map)
1.The attachment should also be populated into the custom table (for this i wrote fix script in global domain but it RCA warning )
2.The activity stream should be same as the record in the security table (the record getting created as per the user who run the import set, but it should be like the original creator and only latest work notes are getting added but all the work notes on the record should be copied)
The record we are importing into the custom security table should be same as security table
please suggest best approach to achieve this
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 hours ago - last edited 3 hours ago
Hello @nedunoorish
Import Set / Transform map is ETL (extract transform load) -- Avoid treating it as clone.
When you import via import Set / Transform Map, ServiceNow treats this as new record due to which Attachments are not automatically linked because you may have already seen sys_attachment records uses table sys_id as shown below and the domain separation here to me seems like block cross-domain attachment.
The above also explains the RCA Warnings because you are rewriting system tables "sys_attachment" and "sys_attachment_doc (as in ServiceNow attachment is not just one record).
The above explanation is also tru for Activity stream as it is not just one field rather has sys_journal_field(work_notes, comments), sys_audit (field changes), sys_history_* tables and metadata about sys_created_by and sys_created_on.
The imported records will start to show created under the import user with which you will lose journal's sys_created by as well as timestamps (just like we use autoSysFields(false) to avoid such).
My recommendation would be to code to achieve this via Fix Script or Background script:
1. GlideRecord the Security Inciden table for the trageted records using the correct addQuery or encodedQuery and within the while loop GlideRecord your custom table and initialize to copy the fields and their values and if you want to retain Sys fields then you can use autoSysFields(false) to prevent the sys_* fields to retain the original values.
2. GlideSysAttachment() to copy as shown under section "This example shows how to copy attachments from an incident record to a problem record.": https://www.servicenow.com/docs/r/api-reference/server-api-reference/GlideSysAttachmentGlobalAPI.htm...
3. Copy the work_notes and/or comments same way as #1 where you must use below:
oldJournalEntryVariable.sys_created_by = newJournalEntryVariable.sys_created_by;
oldJournalEntryVariable.sys_created_on = newJournalEntryVariable.sys_created_on;
Hope that helps!
