To generate a report in ServiceNow showing all ALM (Application Lifecycle Management) Hardware records that transitioned from "In Use" to "In Stock" along with the timestamps for these state changes, you'll need to leverage ServiceNow's reporting capabilities, specifically focusing on the Audit or History of changes for the Hardware [cmdb_ci_hardware] table. Here’s a step-by-step guide to help you achieve this:
Method 1: Using Audit History (Recommended for Change Timestamps)
-
Navigate to Reports > Create New:
- Click on the Reports module in your ServiceNow instance.
- Click on Create New.
-
Select Report Source:
- Source Type: Table
- Table: Hardware [cmdb_ci_hardware]
- Click Next.
-
Configure Report:
- Filter:
- Add Filter:
- Field:
State (and possibly other filters you might need, e.g., Company, Location)
- Operator:
=
- Value:
In Stock (to initially focus on items currently in stock that were previously in use)
- Optionally, add more filters as necessary (e.g., date ranges).
- Add Column:
- You'll primarily be interested in columns like
Name, State, but since you want the transition history, you'll focus on the audit/history aspect next.
-
Accessing State Change History:
- Since the direct report won’t show historical state changes, you'll use a workaround by referencing the Audit or System History module for state changes. However, for a straightforward report, you might need to:
- Use a Scripted Filter or a Custom Report with Script to fetch related audit records showing state transitions from "In Use" to "In Stock". This approach requires advanced ServiceNow scripting knowledge.
Alternative Approach for Scripted Solution (Simplified Overview):
- Create a Custom Report with Script:
- In the report configuration, under Filter or Script, you can use a scripted condition to fetch records based on audit history. Here's a simplified script concept (this will need adjustment based on your exact requirements and ServiceNow version):
// Simplified Concept - Needs Adjustment
var hw = new GlideRecord('cmdb_ci_hardware');
hw.addQuery('state', 'In Stock'); // Currently in stock
hw.query();
while (hw.next()) {
var audit = new GlideRecord('sys_audit');
audit.addQuery('documentkey', hw.sys_id);
audit.addQuery('field_name', 'state');
audit.addQuery('new_value', 'In Stock'); // Changed to In Stock
audit.addQuery('old_value', 'In Use'); // From In Use
audit.query();
while (audit.next()) {
// Process the audit record here, e.g., displaying the timestamp of the change
var changeTimestamp = audit.sys_created_on;
// Either display this in the report directly (if feasible with your scripting approach)
// or store it in a custom field on the hardware record for reporting purposes.
gs.log("Transition Timestamp: " + changeTimestamp); // Log the timestamp for debugging or reference
}
}
Integrating the Script into a Custom Report:
-
Add a Scripted Filter:
- In the report configuration, go to the Filter section.
- Click Add Filter.
- Select Script as the filter type.
- Use the script above to define the logic for fetching the desired records.
-
Use a Custom Report with Script:
- Create a new report or edit an existing one.
- In the report's Advanced tab, you can add a custom script to process the data.
- Use the provided script as a starting point to fetch and display the transition timestamps.
Method 2: Leveraging System History (UI Approach, Limited to Recent Changes)
For a more UI-driven approach without scripting (though less customizable for historical data beyond the system’s standard history retention):
-
Navigate to System History:
- Go to System Diagnostics > System History.
- Table Name: Select
Hardware [cmdb_ci_hardware].
- Field Name: Select
State.
-
Filter Changes:
- Filter by Old Value =
In Use and New Value = In Stock.
- Adjust the Created date filter to capture the timeframe of interest.
-
Review Changes:
- This will show you a list of state changes from "In Use" to "In Stock" within the system’s history retention period.
Reporting Limitation with System History: This method is more about auditing recent changes rather than generating a report on all historical state transitions, which might be limited by your system's configuration for retaining audit history.
Conclusion
For a comprehensive report on all historical transitions from "In Use" to "In Stock" including exact timestamps, a scripted custom report (Method 1's alternative approach) is likely your best bet, despite requiring more technical expertise. If you're looking for a quicker, less customizable solution for recent changes, System History might suffice, keeping in mind its limitations.