how do I remove this server from business service.I have marked this server to non operational and install status to retire this is still showing in business service.
Assistant
To remove a server from a Business Service in ServiceNow, especially one marked as non-operational and set to a retire install status, but still showing up in Business Services, you'll likely want to create or modify a business rule to automate this process. Business Rules in ServiceNow run automatically in response to specified database operations (like inserts, updates, or deletes) within the platform.
Below I will guide you through creating a business rule to handle this situation. This rule will trigger when there are changes to a server's operational status or install status, and it will automatically remove the server from associated Business Services if it meets your specified conditions (non-operational and retire status).
Step 1: Define the Business Rule
Go to ServiceNow Dashboard.
In the left-hand navigation panel, type and select "Business Rules" under System Definition.
Step 2: Create a New Business Rule
Click on "New" to create a new Business Rule.
Name the Rule: Give it a descriptive name, e.g., "Remove Retired Server from Business Service".
Table: Choose the table relevant to your servers. This might typically be the CI (Configuration Item) table or a specific server table if customized (e.g., cmdb_ci_server).
When to run: Set the rule to run on update.
Make sure to check the conditions under which the rule should execute. You can choose:
Condition/Advanced: Use the condition builder or advanced condition script to specify:
Operational Status is 'Non Operational'
Install Status is 'Retire'
Step 3: Specify the Action
In the "Advanced" tab, enable the "Advanced" checkbox and insert a script to remove the server from any linked Business Services. Below is a sample script in JavaScript:
javascript
(function executeRule(current, previous /*null when async*/) {
// Check if the server is marked non-operational and set to retire
if (current.operational_status == 'non_operational' && current.install_status == 'retire') {
// Query for related business services
var rel = new GlideRecord('cmdb_rel_ci');
rel.addQuery('child', current.sys_id); // or 'parent' based on your setup
rel.query();
while(rel.next()) {
// Assuming 'type' is the field that links to a Business Service; adjust field names as necessary
if (rel.type.getDisplayValue() == 'Uses::Used by') {
rel.deleteRecord(); // Remove the relationship
}
}
}
})(current, previous);
This script checks if the updated server is set to the specified operational and installation statuses, and if so, it iterates over related records in the relationship table (adjust according to your table setup) and removes the relationship entries related to Business Services.
Step 4: Testing and Validation
After setting up the business rule, test it by updating a server record to see if it automatically gets disassociated from Business Services as intended.
Verify the integrity of related business service configurations to ensure no unintended modifications occur.
Step 5: Documentation and Deployment
Document your changes and inform relevant teams about this automation—particularly those managing servers and business services.
Move your Business Rule through the appropriate development, testing, and production environments using your organization's change management practices.
Make sure that you have proper access permissions to create business rules and modify CI and Business Service configurations in ServiceNow. If not, you may need to work with your ServiceNow administrator.