Managing aging hardware is one of those tasks that sounds simple but becomes complex very quickly at scale. Different assets come from different vendors, have different warranties, and follow different lifecycle rules. Without automation, retirement dates are often missing, inconsistent, or simply wrong. This ServiceNow script addresses that challenge by systematically determining and populating retirement dates for hardware assets using a clear, prioritized logic.
At a high level, the script’s goal is to ensure that every hardware asset has a meaningful retirement date, using the best available data. It does this by working through four logical steps, starting with the most reliable information and falling back to defaults only when necessary.
Follow along with the script at the bottom of the article.
The script begins by standardizing the concept of useful life at the model level. It queries the cmdb_hardware_product_model table and finds any hardware models where the useful_life field is empty. For those models, it sets a default useful life of 36 months.
This step is important because many downstream calculations depend on the model’s useful life. By ensuring that no model is missing this value, the script creates a reliable baseline. While 36 months is used as a default, the structure allows for future customization—such as assigning different lifespans to laptops, servers, or network equipment.
Next, the script moves to the asset level and looks at hardware records in the alm_hardware table. For assets that have a warranty expiration date, it sets the asset’s retirement date to match that warranty end date.
This makes sense from a business perspective. Once a warranty expires, the organization often assumes increased risk and maintenance cost. Using the warranty expiration as the retirement date ensures that assets are flagged for replacement or review at the appropriate time.
Not all assets have warranty information. For assets that still lack a retirement date but do have an associated model, the script looks to the model’s lifecycle records. It queries the cmdb_hardware_model_lifecycle table to find an active end-of-life phase for the model.
If an end-of-life date exists, that date becomes the asset’s retirement date. This aligns asset management with vendor lifecycle data, ensuring that hardware is not kept in service beyond its supported lifespan.
Finally, for assets that still don’t meet any of the previous criteria, the script uses a calculated approach. It takes the asset’s creation date and adds the model’s useful life (in months) to determine a retirement date.
This is the ultimate fallback option, but it ensures that no asset is left without a retirement date. Even when data is incomplete, the system still produces a reasonable and predictable result.
This script is a great example of defensive, real-world ServiceNow development. It prioritizes the most accurate data sources, gracefully handles missing information, and ensures consistent outcomes across thousands of records. By automating retirement date management, organizations gain better visibility into aging hardware, reduce operational risk, and support more informed refresh planning—all without manual intervention.
In short, this script turns scattered lifecycle data into a dependable, automated asset aging strategy.
Automating hardware retirement dates in ServiceNow ensures every asset has a consistent, defensible lifecycle plan. By leveraging warranty data, model lifecycle records, and useful life logic, you create cleaner data and more reliable refresh planning.
Want to implement this in your environment? Contact us to get started.
We go further and faster when we collaborate. Geek out with our team of engineers on our learnings, insights, and best practices to unlock maximum value and begin your business transformation today.
RapDev engineers real-time retail operations on ServiceNow for global customers
Leverage AI and automation in operations, secure data, and embed compliance into every workflow