How to modify current sys_id value with previous sys_id
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2023 08:01 AM
Hi Expert
I have requirement where I have to update to the current sys_id value with the previous sys_id value.
For Example, In my dev isntance I have a CI as A and sys_id is ccbb23231212121. However, in my test instance same CI (A) has different sys_id value like kkkk121212121212. So, my requirement is to update the CI in the test instance with dev instance sys_id value.
Can someone please help me with the above requirement. I have to write fix script for this or background script or anything. If possible, please help with script part as well. How can I achieve this requirement?
Thanks in Advanced
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2023 08:06 AM
Hi @Prasnajeet1 ,
Changing the sys_id will not help you in this case.
You can delete the record in dev with sys_id - ccbb23231212121 and import xml of record from test instance with sys_id - kkkk121212121212 into Dev instance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2023 10:19 AM
Hi Manmohan
Thats not the requirement actually.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2023 01:03 PM - edited ‎05-29-2023 01:03 PM
The following script will show how to reassign a SysID:
var ci1Gr = new GlideRecord('cmdb_ci'); // ... assume this is a valid record (e.g. via ci1Gr.get)
var ci2Gr = new GlideRecord('cmdb_ci'); // assume this is a valid record as well
var ci2SysID = ci2Gr.getUniqueValue(); // save the SysID before deletion
ci2Gr.deleteRecord();
// assign the SysID of CI2 to CI1
ci1Gr.setNewGuidValue(ci2SysID);
ci1Gr.update();