Sometime ago I migrated data from one ServiceNow instance to another. Both instances had company and user data, which were not in sync with each other and the new instance ended up with a number of duplicate companies. Manually copying fields and references from one company to another is not very efficient. There has to be an easier way.
This is an example of how you can merge two company records with a UI action together with a GlideDialogWindow and a Script Include. I have made the setup as generic as I possibly could, so that it can be used on other tables without any/much customizations.

Example merge 2 companies

The UI Action calls a UI page and the UI page calls a script include, which is doing most of the work.The following data is copied from the record on which you trigger the UI Action (source) to the record, which you select in the GlideDialogWindow (target):

  • Fields (excluding system fields and empty fields)
  • References to the source record
  • Attachments
  • Field attachments

You can set a parameter to copy source fields to the corresponding target field when the target field is not empty. Default target fields, which are not empty, are not overwritten.
The UI action also does not delete the duplicate record (source), but sets the record to inactive if possible.
Continue reading…»