Transform functions
Summarize
Summary of Transform functions
Transform functions in ServiceNow enable you to manipulate and reformat data pill values within flows without writing scripts. These functions cover multiple categories such as date and time, string manipulation, utilities, simple math, sanitizing shell arguments and SQL, and handling complex data. They help ensure data integrity, prevent injection attacks, and support integration scenarios by transforming data into required formats.
Show less
Applying and Managing Transform Functions
- To apply a transform function, select the f(x) icon next to a data pill during flow or action design, choose the desired function, provide required inputs, and apply it.
- Multiple transform functions can be applied sequentially to the same data pill; they execute in the order listed.
- You can view applied transform functions both in the design interface and in flow execution details.
- The system may automatically suggest relevant transform function categories based on the input context, such as sanitizing SQL in JDBC steps or shell arguments in SSH steps.
Best Practices and Guidelines
- Ensure transform functions are applied to compatible data pill types; incompatible applications are skipped or cause errors.
- Transform functions generate new runtime values per input and do not modify the original data pill; apply functions to each input individually if the data pill is reused.
- Only the final transformed value is visible in flow execution details, not intermediate function outputs.
- Test flows or actions to verify transform functions produce expected results before deployment.
- Custom transform functions are not supported; for advanced scenarios, use inline scripts in Workflow Studio.
Transform Function Categories and Use Cases
- Date and time: Adjust or reformat Date/Time values, such as adding time to localize timestamps.
- String: Modify strings by trimming whitespace or performing other textual manipulations.
- Utilities: Extract values from complex objects or arrays.
- Simple math: Perform basic mathematical operations on numeric data pills.
- Sanitize shell arguments: Clean string inputs to prevent injection attacks in shell scripting contexts.
- Sanitize SQL: Escape special characters to prevent SQL injection in database queries.
- Complex data: Serialize complex objects into raw XML, useful for REST request bodies.
Transform data pill values without the need to write a script. Use transform functions to reformat text, perform mathematical calculations, sanitize potentially unsafe SQL statements, and serialize complex objects to raw XML.
Available transform function categories include date and time, string, utilities, simple math, sanitize shell arguments, sanitize SQL, and complex data. Some examples of transform function uses include:
- Trimming white space from a string before integrating it into the CMDB.
- Adding days, hours, minutes, and seconds to a date or time to localize for a specific time zone.
- Sanitizing SQL values to prevent injection as part of a JDBC step for an Integration Hub spoke.
- Retrieving an appropriate value from a map of priorities that have equivalent values in a third-party database.
- Transforming a complex object into raw XML as part of a REST step Request Body field.
Applying a transform function
You can apply a transform function to a data pill when you are designing or creating a
flow. To apply a transform function, point or tab to a data pill and select the
f(x) () icon that appears. Selecting the icon displays the Available Transforms list.
Select the transform function that you want to apply to your data pill, enter information
into any required fields, and select Apply. Your selected transform
function appears in the Applied Transforms list.
Applying multiple transform functions
You can apply multiple transform functions to the same data pill. The system applies transform functions sequentially from top to bottom as listed in the Applied Transforms list. For example, you can apply a String to Date transform function followed by the Add Time transform function.
Viewing applied transform functions
- For data pills dropped in the JDBC step's SQL Statement input, the sanitize SQL transform function category is displayed automatically.
- For data pills dropped in the SSH step's Command input, the sanitize shell arguments transform function category is displayed automatically.
General guidelines
- Apply transform functions to valid types of data pills for the input
- Be sure to check the type of data pill for the input before applying a transform function. Applying a transform function to an invalid data pill type results in the system skipping the transform. An error also occurs if transform functions produce results that the system cannot parse. For example, when transforming a string into a date, the system throws an error if the transform does not produce a valid date.
- Confirm applied transform functions for multiple inputs with the same data pill
- A transform function creates a new value at runtime for a specific input, and does not change the original data pill. If you use the same data pill across multiple actions or steps, transform functions must therefore be applied to each individual input.
- View final transformed values in the flow execution details
- Only the final transformed value appears in the flow execution details, and not the value for each applied transform.
- Test transform functions to verify they produce expected results
- Make sure that your transform functions produce the expected runtime values for the data pills. For more information, see Test a flow and Test an action.