Astik Thombare
Tera Sage

ChatGPT Image May 27, 2026, 01_28_27 AM.png

 

One common pattern I’ve noticed while developing flows in ServiceNow is that many developers immediately start writing scripts whenever they need to manipulate a value inside Flow Designer.

 

Typical approaches include:

  • Creating additional flow variables
  • Adding Script steps
  • Writing inline scripts for simple formatting
  • Using unnecessary custom actions

But is scripting always required?

 

The answer is No.

 

ServiceNow already provides a powerful built-in capability called Transform Functions, which allows developers to manipulate data pill values directly inside Flow Designer without writing code.

Since ServiceNow is designed as a low-code platform, we should always prefer native functionality before introducing unnecessary scripting.

 

What Are Transform Functions?

 

Transform Functions allow you to transform and manipulate data pill values directly inside Flow Designer.

 

Using transform functions, you can:

  • Reformat text
  • Modify date and time values
  • Perform mathematical calculations
  • Sanitize SQL statements
  • Sanitize shell commands
  • Serialize complex objects into XML
  • Clean and standardize integration payloads

All of this can be done without writing a single line of script.

 

Available Transform Function Categories

 

Category Purpose Common Use Cases
Date and Time Modify or format dates and timestamps Add days, convert time zones, format dates
String Manipulate text values Trim spaces, replace characters, convert case
Utilities Perform utility operations Handle null values, conditional formatting
Simple Math Execute calculations Add, subtract, multiply values
Sanitize Shell Arguments Secure SSH command inputs Prevent shell injection
Sanitize SQL Secure JDBC queries Prevent SQL injection
Complex Data Handle structured data objects Convert objects into XML

 

Why Developers Should Prefer Transform Functions

Many simple scripting use cases can already be handled using transform functions.

Using transform functions helps:

  • Reduce unnecessary scripting
  • Improve maintainability
  • Make flows easier to understand
  • Improve security
  • Follow low-code development best practices

Before creating a Script step, always ask yourself:

“Can this requirement be solved using a transform function?”

In many cases, the answer is yes.

 

Real Project Examples

 

1. Remove Special Characters or Prefixes from User Names

 

While submitting catalog items or sending data to external systems, user names may contain prefixes like:

  • Dr.
  • Mr.
  • Mrs.
  • Jr.

Instead of scripting, String transform functions can clean the value before integration.

 

Example

 

Input:

 

Dr. John Smith Jr.

 

Output:

 

John Smith

 

 

AstikThombare_0-1779880098956.png

2. Retry Integration Payloads Without Rebuilding Scripts

 

Many times in integrations, third-party systems may be temporarily unavailable due to outages or downtime.

A common requirement is:

  • Retry the same payload multiple times
  • Retry after a fixed interval like 15 minutes
  • Create an Incident or Task if all retries fail

Many developers handle this by:

  • Creating a flow variable like retry_count
  • Writing Script steps to increment the variable
  • Rebuilding payload logic repeatedly using scripts

 

retry_count = retry_count + 1

If retry_count >= 3
→ Create Incident or Task
Else
→ Wait 15 Minutes and Retry

 

Instead of writing scripts for incrementing values, we can use Transform Functions directly on the data pill.

For example:

  • Grab the retry count data pill
  • Use a Simple Math transform function
  • Increment the value by 1 during every retry iteration

This keeps the flow:

  • More low-code
  • Cleaner
  • Easier to maintain
  • Less dependent on Script steps

 

Call REST API
      ↓
If Failed
      ↓
Wait 15 Minutes
      ↓
Increment Retry Count using Transform Function
      ↓
Retry up to 3 Times
      ↓
Still Failed?
      ↓
Create Incident / Task

 

 

AstikThombare_0-1779883525751.png

 

3. Trim White Spaces Before Updating CMDB Records

 

External integrations often send values with extra spaces.

 

Example

 

Input:

 

        Windows Server 2022

 

Output after Trim transform:

 

Windows Server 2022

 

AstikThombare_0-1779884871728.png

 

OR 

AstikThombare_0-1779886210242.png

 

4. Convert and Localize Date/Time Values

 

Transform functions can dynamically:

  • Add days
  • Add hours
  • Add minutes
  • Reformat timestamps

This becomes extremely useful when integrating with systems operating in different time zones.

Example:

  • Convert UTC timestamps to local time
  • Add SLA buffer times
  • Calculate expiry dates dynamically

 

5. Secure JDBC Queries Using Sanitize SQL

 

When using JDBC steps in Integration Hub, developers often pass dynamic values inside SQL queries.

 

Transform functions help sanitize those values and reduce risks like:

  • SQL Injection
  • Broken queries
  • Invalid formatting

This improves both security and reliability.

 

6. Secure SSH Commands Using Sanitize Shell Arguments

 

When executing SSH commands dynamically, special characters inside values may break commands or create security risks.

 

Using the Sanitize Shell Arguments transform function helps:

  • Escape special characters
  • Prevent shell injection
  • Improve command reliability

7. Convert Complex Objects into XML

Some external APIs require XML payloads instead of JSON.

Using Complex Data transform functions, developers can serialize objects directly into raw XML without writing custom conversion scripts.

How to Apply a Transform Function

 

Applying a transform function in Flow Designer is very simple.

Steps

  1. Open the Flow or Action
  2. Hover over the required data pill
  3. Click the f(x) icon
  4. Select the required transform function
  5. Configure required parameters
  6. Click Apply

 

apply-transform-function-orlando.gif

 

Once applied, the transform appears in the Applied Transforms section.

Applying Multiple Transform Functions

Flow Designer also supports multiple transform functions on the same data pill.

The transforms execute sequentially from top to bottom.

Example

You can:

  1. Convert String → Date
  2. Add Time
  3. Format the Date Output

This creates a clean transformation pipeline without scripting.

Viewing Applied Transform Functions

 

To verify applied transforms:

  1. Hover over the data pill
  2. Click the f(x) icon
  3. Review the Applied Transforms list

You can also validate transformed values inside:

  • Flow Execution Details
  • Action Execution Details

Note: Execution details only display the final transformed value and not each intermediate transformation.

 

Important Best Practices

 

1. Use Transform Functions on Valid Data Types

Always ensure the data pill type matches the transform function.

Examples:

  • String transforms should use String values
  • Date transforms should use Date values

Invalid transformations may be skipped or generate runtime errors.

 

2. Transform Functions Do Not Modify the Original Data Pill

Transform functions create a new runtime value only for that specific input.

If the same data pill is used in multiple steps, transforms must be applied separately for each usage.

 

3. Test Runtime Outputs Properly

Always test flows and actions to ensure transformed values behave correctly during execution.

This is especially important for:

  • Integrations
  • SQL queries
  • Date calculations
  • XML payloads

Additional Practical Use Cases

 

Requirement Recommended Transform
Convert email IDs to lowercase String
Remove spaces from employee IDs String
Add 30 days to expiry date Date and Time
Calculate percentages Simple Math
Escape SQL special characters Sanitize SQL
Escape shell command arguments Sanitize Shell Arguments
Convert payload objects to XML Complex Data

 

Final Thoughts

 

Transform Functions are one of the most underrated capabilities in ServiceNow Flow Designer.

Many developers introduce unnecessary Script steps for operations that can easily be handled using native low-code functionality.

By properly using Transform Functions, developers can:

  • Reduce scripting effort
  • Build cleaner flows
  • Improve maintainability
  • Improve security
  • Align with low-code best practices

The next time you start creating a Script step in Flow Designer, first check whether a Transform Function can solve the requirement.

You may be surprised how much can be achieved without writing code.

 

Author

Astik Thombare
ServiceNow Developer | Automation Enthusiast | Low-Code Advocate

I regularly share practical ServiceNow development tips, Flow Designer solutions, integrations, and real-world implementation examples.

Connect with me on LinkedIn:
LinkedIn Profile