To delete orphan connection and credential aliases, a System Admin can run a background script in the global scope. The cleanup targets aliases that no longer label any records. Before you run it, check what the script really selects and how it tests connections. The DevOps example filters alias names and checks HTTP connections. It does not check every possible dependency.
Define which aliases belong in the cleanup
An alias that looks unused needs a closer look before you delete it. A name, an old creation date, or an unfamiliar application scope does not establish that the record is orphaned. Start with the relationship between the alias and the connection or credential it identifies. Keep the cleanup list separate from a broader inventory of aliases that merely need an owner.
The DevOps cleanup works on the sys_alias table. Its encoded query, nameSTARTSWITHDevOps-_-, limits candidates to names that begin with DevOps-_-. For each candidate, it searches the HTTP connection table for a connection_alias reference equal to the sys_id of the alias record. If an HTTP connection matches, the alias stays. If none matches, the alias is deleted.
That distinction determines the safe boundary of the work. The script does not inspect a general dependency inventory, examine application configuration, or independently query credential records. Read the script’s result as one HTTP connection check, not as a full dependency review.
If you need to establish how alias records relate to integrations before selecting candidates, review connection and credential alias relationships. Settle questions of ownership before you put a record on the deletion list.
Inspect connections, credentials, and application references
Review the candidate alias with the application owner. In an alias configuration, the Connections related list helps identify associated connections. Inspect the Connection alias and Credential fields on the connection, along with its connection type. A failed authentication attempt does not demonstrate that these relationships are absent; repair and retirement require different decisions.
The Google Sheets alias configuration shows why the connection type matters. Its Connection type choices include Basic, HTTP, JDBC, JMS, and Kafka. Connections can be associated with an alias through the Connections related list using the Connections [sys_connection] table. An HTTP-specific lookup cannot stand in for a review of those other connection types.
The Google Sheets alias starts as a record on the Connection & Credential Aliases list, reached from All > Connections & Credentials. Its Name field takes only letters, numbers, and underscores, so Sheets_Alias is a valid name. Its Type field is either Credential or Connection and Credential. It defaults to Connection and Credential. Its Connection type field defaults to HTTP. The Support Multiple Active Connections option sets whether the alias can hold more than one active connection. The Connections related list is where those connections are associated with it. On an HTTP(s) connection, the Connection alias field resolves the connection and its credentials at run time. The Active option sets whether that connection is on. The OAuth 2.0 credential used with the alias needs its Integration Type set to Personal. The setup steps ask you to select this after you open the credential record.
Also check settings that name an alias directly. The Google Sheets export configuration stores an alias sys_id in the glide.oauth.export.to.sheets.alias system property. As an admin, compare that value with the identifier of a candidate when the integration is in scope. If a property holds the identifier, investigate the integration’s intended configuration before you delete its alias.
Parent and child aliases need a separate look. The Google Calendar personal authentication configuration uses a child alias whose connection inherits properties from its parent. The checks for that configuration need admin and the Google Calendar Spoke application scope. Review the relationship as a unit instead of deciding from one record’s display name.
For Discovery environments, keep alias review connected to the separate inventory of credentials required for host Discovery. Removing an alias is a different task from deciding whether a device authentication credential remains necessary.
Prepare to delete orphan connection and credential aliases
The background cleanup needs System Admin (admin). Go to All > System Definitions > Scripts – Background and select global as the scope. Check this path and behavior on your instance and release before you run it. The steps here describe the Brazil cleanup behavior.
- Record the alias name prefix you intend to use and the application that made those records. Confirm that DevOps-_- is the intended boundary for this cleanup.
- Capture candidate identifiers and their current relationships in the change record. Keep credentials and authentication secrets out of that record.
- Review the connection lookup with a second administrator. It should compare connection_alias with the current alias identifier, not a display name.
- Rehearse the selection and checks in a representative nonproduction environment. Compare the candidates with the retirement list from the application owner.
- Arrange a recoverable record of the affected configuration before allowing deletion. Decide who will validate the dependent integration afterward.
These preparation steps are recommendations for operating. They make the deletion decision easy to review, especially when an integration is being retired along with other configuration changes. The role you need to run the cleanup does not replace the application owner’s decision on whether the alias should stay.
Understand and execute the background script
Place the reviewed JavaScript in the Run script (JavaScript executed on server) pane. The deletion logic has three parts. It selects aliases with the intended prefix. It checks each alias for an HTTP connection. It deletes the alias when that check finds nothing. Read the condition just above the deletion call before you select Run script. Log each candidate sys_id, name, and connection lookup result first, so the list you reviewed is the list that runs.
The key expressions are GlideRecord(‘sys_alias’), addEncodedQuery(“nameSTARTSWITHDevOps-_-“), and query() for picking candidates. For the link check, the HTTP connection lookup uses addEncodedQuery(“connection_alias=” + sysAliasId). Its next() result shows whether an HTTP connection exists. The alias deleteRecord() call belongs behind a negative result from that lookup.
Keep the candidate query and the relationship query distinct during review. The first answers which aliases the script will examine. The second answers whether a selected alias has an HTTP connection. Removing the prefix expands the population being examined without expanding the types of relationships being checked.
The connection lookup does not filter on Active. So an inactive HTTP connection that still points to the alias passes the existence check. Do not change that behavior just because the connection is inactive. Deciding to retire that connection needs its own review.
When the reviewed script and candidate scope match the approved change, select Run script. Record that the execution occurred and proceed to validation. Avoid an immediate second execution based solely on an unexpected count or an assumption that the first run should have removed more records.
Validate retained aliases and investigate exceptions
Compare the resulting alias inventory with the approved candidates. Confirm that the expected deletions happened and that aliases with HTTP connections remain. Retention is consistent with the script when a matching connection_alias reference exists, even if the administrator did not expect that connection to be present. Check that the removal count matches the number of logged candidates with no HTTP connection match.
For a retained alias, look at the matching connection before you adjust the script. Check its purpose, the credential it selects, and whether its application is still needed. If authentication is failing, investigate the credential and connection configuration rather than treating deletion as an authentication repair. Record its Active state with its owner in the handover, so no one mistakes a retained alias for a working integration.
The vendor advisory configuration shows this split well. To create its connection, you select the credential record in Credential and supply Connection URL. The configuration action needs sn_vul.vulnerability_admin, sn_vul.admin (deprecated), or admin. Those roles apply to that configuration procedure. The background deletion procedure needs System Admin (admin).
Where credentials are managed outside the instance, work with the owner of external credential storage on the review. Do not assume that removing an alias has retired the matching secret or finished a credential lifecycle change. Ask that owner whether the stored secret is still in use before you retire any alias that points at it.
Close the cleanup with identifiers, observed removals, retained exceptions, and application validation results. Record storage reduction as the purpose of removing redundant records without promising a particular capacity gain or performance improvement. If candidates remain unresolved, leave them assigned for investigation rather than broadening the deletion condition during the same change.
Put the final candidate list in the handover so a later administrator can tell aliases kept on purpose from records that were missed. Note any pending application retirement on its own. This prevents the next cleanup from repeating the same ownership investigation without access to the earlier decision.
For help planning or carrying out this work on your instance, see our ServiceNow implementation services.