servicenow calculated field example

Mastering ServiceNow: Calculated Field Example

By John Garcia
AD

ServiceNow's platform offers immense flexibility through the use of calculated fields. These dynamic fields allow you to perform real-time calculations, format dates, or convert values based on specific criteria, enhancing your instance's functionality. Let's explore some practical examples of calculated fields in ServiceNow to help you leverage this powerful feature.

Firstly, let's understand why calculated fields are so useful. They automate data manipulation, freeing up time for more strategic tasks, and ensure consistent data format and accuracy across your instance. Now, let's dive into some real-life use cases.

Date Manipulation

ServiceNow calculated fields excel at manipulating dates and times. Here, we'll create a new field called "Days Until Due" that calculates the number of days between the present date and a target due date.

AD
How to Break Into ServiceNow in 2026
How to Break Into ServiceNow in 2026
ServiceNow Table Management
ServiceNow Table Management
ServiceNow: Request Management
ServiceNow: Request Management

Field settings:

  • Field label: Days Until Due
  • Field type: Calculated date
  • Expression: floors(abs(due_date - now()));

The "due_date" term refers to the target due date, "now()" fetches the present date and time, and the expression calculates the absolute difference, rounded down to the nearest whole number (since it's impractical to have a fraction of a day).

the servicenow logo surrounded by icons and symbols on a dark background with yellow accents
the servicenow logo surrounded by icons and symbols on a dark background with yellow accents
Workday Calculated Fields: The Logic Behind Smart Workflows
Workday Calculated Fields: The Logic Behind Smart Workflows
ServiceNow Outage Tracking.
ServiceNow Outage Tracking.

Formatting Dates

Not all date fields need to display dates in the default format. Sometimes you might want to display dates in a specific format, like "Month Day, Year" (e.g., "March 21, 2023").

Field settings:

AD
  • Field label: Due Date (Formatted)
  • Field type: Calculated date
  • Expression: format(due_date, 'MMMM d, yyyy');

The "due_date" term remains the same, but the expression now uses ServiceNow's "format" function to display the date in the desired format.

Дизайн приложений | Разработка интерфейса, Дизайн интерфейса, Дизайн ui ux
Дизайн приложений | Разработка интерфейса, Дизайн интерфейса, Дизайн ui ux
Most people think ServiceNow = ITSM.
Most people think ServiceNow = ITSM.
Planning a ServiceNow implementation?
Planning a ServiceNow implementation?
ServiceNow ITSM KPIs Every Professional Should Know
ServiceNow ITSM KPIs Every Professional Should Know
Is Your ServiceNow Application Developer Career Future-Proof?
Is Your ServiceNow Application Developer Career Future-Proof?
ServiceNow - Supported User interfaces
ServiceNow - Supported User interfaces

Conditional Calculations

Calculated fields aren't limited to simple mathematical expressions. You can use conditional statements (IF, CASE, ETC.) to return different values based on specific criteria. Let's create a "Priority Tier" field that categorizes tasks based on their 'Priority' field.

Field settings:

AD
  • Field label: Priority Tier
  • Field type: Calculated text
  • Expression: case(priority, 1, 'Low', 2, 'Medium', 3, 'High', 4, 'Critical', 'Unknown' )

This calculated field uses the "case" function to check the value of the 'priority' field, and based on that, assigns the task to a 'tier': Low, Medium, High, or Critical. If the 'priority' field isn't defined, it defaults to 'Unknown'.

Work order architecture - Dynamics 365 Field Service
Work order architecture - Dynamics 365 Field Service

Currency Conversion

While ServiceNow doesn't handle currency fields natively, you can still create calculated fields to convert values between different currencies. To do this, you'll first need to set up a table containing up-to-date exchange rates.

Assuming you have an "Exchange Rates" table with 'Currency' and 'Rate' fields, and you want to convert a "Value in USD" field to a user's local currency:

AD

Field settings:

  • Field label: Value in Local Currency
  • Field type: Calculated number
  • Expression: sco_get discrete_value('Exchange Rates', 'Rate', 'Currency', current_user.location.preferred_language); * value_in_usd;

The "sco_get" function retrieves the 'Rate' value from the "Exchange Rates" table for the user's preferred language, and then multiplies it with the "Value in USD" field.

Calculated fields in ServiceNow are an essential tool for enhancing your instance's functionality and automating data manipulation tasks. Explore the countless possibilities they offer, and adapt them to your specific needs. Happy calculating!

AD