Dedup/Merge of CI extended table

snowE
Tera Contributor

Hi All,

I have a requirement where we are removing SDLC component table (extended from cmdb_ci). Before we remove this, we want to merge the related list items and relationships from these records to a corresponding Application Service record. My first thought was to use Dedup/Merge, but because there are 120 records, it is a lot of manual work. Is there a better way or script to achieve this? Any leads or help appreciated

5 REPLIES 5

Bert_c1
Kilo Patron

Hi @snowE,

 

I see that the cmdb_ci_service_auto extends cmdb_ci_service, extends cmdb_ci. And cmdb_ci_sdlc_component extends cmdb_ci.  So you can write a script to process records in the  cmdb_ci_sdlc_component table, and then update fields in the cmdb_ci_service_auto table. Those Reference fields on both should still be valid. If there are reference fields on the cmdb_ci_sdlc_component that do not exist on the cmdb_ci_service_auto table, then those won't "transfer" and you'll need to add custom fields to cmdb_di_service_auto, and the script will have to populate values from the cmdb_ci_sdlc_component table.

snowE
Tera Contributor

Do you have an example script which merges Related list records like INC CHG and CI relationships?

No, you need to be specific on which tables have a List field that references the 'cmdb_ci_sdlc_component ' table. And the field names on those tables. Once known, then a script can be written.

 

But I see that in my instance, I don't have any Reference or List fields for the 'cmdb_ci_sdlc_component' table.

 

https://[instance_name].service-now.com/sys_dictionary_list.do?sysparm_query=internal_type%3Dglide_list%5Ereference%3Dcmdb_ci_sdlc_component&sysparm_view= 

and

https://[instance_name].service-now.com/sys_dictionary_list.do?sysparm_query=internal_type%3Dreference%5Ereference%3Dcmdb_ci_sdlc_component&sysparm_view=

 

both show 0 records

 

I found this:

 

https://www.servicenow.com/community/developer-forum/copying-records-from-one-table-to-another/m-p/1...

 

The accepted solution there Needs testing.

Riya Verma
Kilo Sage
Kilo Sage

Hi @snowE ,

 

Hope you are doing great.

 

Certainly! To achieve this, you can use a scripted approach in ServiceNow. Here's a high-level outline of the steps you can follow:

 

  1. Identify Records for Merge : Use a script to identify the records in the SDLC component table that need to be merged.

  2. Write a script to find the corresponding Application Service record for each SDLC component.

  3. Use GlideRecord queries to copy related list items (like attachments, comments, etc.) from the SDLC component to the corresponding Application Service record.

  4. Update any relationships or references pointing to the SDLC component to now point to the Application Service record.

  5. Update any relationships or references pointing to the SDLC component to now point to the Application Service record.

  6. Once all the data is safely transferred, you can delete the SDLC component records.

 
 
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma