Notifications

936 views

Symptoms


Clone target is not available to clone over after instance(clone target) has been renamed.

Cause


Once the instance is renamed, the instance URL is updated with new name. But clone target record reflects old instance name for that instance. If you open the Clone Target record, the Instance URL field is read-only. 

Resolution


In order to rename the clone target records after an instance rename there is an easy workaround any administrator on the instance should be able to perform.

Approach 1:

You can execute the below script after supplying the 3 instance variables on the /sys.scripts.do page as user with the (security_)admin role.

renameCloneTarget();
function renameCloneTarget() {
 var old_instance_name = 'insertOldInstanceNameHere';
 var instance_id = 'insertInstanceIDhere';
 var new_instance_name = 'insertNewInstanceNameHere';
 var target = new GlideRecord('instance');
 target.addEncodedQuery('source=false^instance_id='+instance_id+'^instance_urlLIKE'+old_instance_name);
 target.setLimit(1);
 target.query();
 while (target.next()) {
  gs.info('Renamed clone target instance "'+old_instance_name+'" with ID instance_id '+instance_id+' to > "'+new_instance_name+'"');
  target.instance_name = new_instance_name;
  target.instance_url = 'https://'+new_instance_name+'.service-now.com';
  target.update();
 }
}

Approach 2:

  1. Navigate to Clone Targets list.
  2. Find the clone target which was renamed, DO NOT OPEN the record.
  3. Double click on the Instance URL value for that record, it should allow you to edit the text for Instance URL.
  4. Change the Instance URL to reflect new instance name and click green check mark to save the record.
  5. Schedule a new clone. 

Approach 3:

  1. Remove all entries for the clones to the old instance name from the clone history list. You may need to configure the delete button to show for admins.
  2. Remove the clone target record. You may need to configure the delete button to show for admins.
  3. Add the clone target with the new name. 

Approach 4 not recommended but if all else fails:

  1. Navigate to Clone Targets.
    You can export the clone target that needs renaming to XML.
  2. Change the following fields to reflect the new instance name using a text editor:
    • <instance_name>
    • <instance_url>
      As long as the target instance URL is OK the rest of the fields, like db properties, get updated via the soap service from the clone automation.
  3. Import the updated XML
    (If the right click option to "Import XML" does not show then navigate to "Retrieved Update Sets" > "Import Update Set from XML" (this way no business rules run when updating the record, this also means you can no track the update))
  4. Schedule a new clone.

Article Information

Last Updated:2019-06-20 04:56:20
Published:2019-06-20