Cruz Melendi
ServiceNow Employee

Custom Data Export with Utility Actions Spoke

 

The Utility Actions spoke provides a complete set of actions for generating delimited files programmatically in Flow Designer. If you need to create extracts from different ServiceNow tables, with custom column names, or formatted headers, this spoke is your secret weapon đŸ’Ł

 

I've used this spoke in two primary scenarios:

  💎 The first involves exporting data with custom headers that differ from the source table's field labels.

  đŸ’Ž The second involves combining data from two unrelated tables in a single export.

Neither of these use cases can be achieved through scheduled reports.

 

IMPORTANT: The Utility Actions spoke requires an active Integration Hub subscription.

 

Defining Your File Schema

 

The first and most important step is to define the structure of your file. The File Schema form specifies the columns, their data types, delimiters, and other formatting options. This schema becomes the blueprint for your extract.

 

You give the schema a name for reference, something like "Incident Export Schema" or "Change Order Schema". You specify the delimiter (comma, tab, pipe, or another character), whether the file includes a header row, and whether values should be quoted to escape delimiters. The most important part is the Columns JSON array, where each column definition specifies a name and data type.

 

Here is a link to the official documentation.

 

The File Generation Flow

 

File generation follows a three-step sequence: begin a file, append content to it, then build and attach the result. This separation gives you the flexibility to handle complex scenarios and implement error handling.

 

⭐Begin File: creates a file record in your instance, think of it as initialisation. The action sets up a record that will eventually hold your generated file. You reference this file record in subsequent steps.

⭐Append to Delimited File: adds rows to your file. Each append operation creates a line record. When you're done appending all your data, the file contains the complete content ready to be built.

⭐Build File: generates the actual file from the appended content and attaches it to the file record. At this point, you have a downloadable file in your instance.

 

This spoke allows us to add the generated file, and more, to a ZIP file. To do that, we need to follow a similar procedure: Begin Zip action, Add File To Zip action and Build a Zip action.

NOTE: The Build Zip action in the spoke requires at least one MID Server with the capability IntegrationHub Utilities or ALL.

 

Here is a link to the official documentation.

 

Field Mapping and Value Translation

 

Real-world extracts often require transformation beyond simple field reference. An incident's urgency field is numeric (1, 2, 3, 4, 5), but your export needs descriptive text (Critical, High, Medium, Low, Planning). A reference field like assignment_group stores the group's sys_id, but you need the group name.

 

Flow Designer lets you extract and transform values. When appending a row, you build the delimited string by referencing fields from your queried records and applying expressions. For reference fields, you use dot-walking to access the related record (assignment_group.name).

 

Performance Considerations

 

🚨There is an impact when working with large datasets. Appending 10,000 rows takes measurably longer than appending 100 rows. Test your workflows with realistic data volumes before production deployment to understand actual execution time and resource demands.

 

🚨Your query performance directly affects overall workflow time. A poorly constructed query that returns thousands of unnecessary records slows everything downstream. Build efficient queries that fetch only the data you need; use filters, limits, and indexed fields where possible.

 

🚨Run export workflows during off-peak hours when instance processing load is low. This prevents the extract from competing with daily business operations and reduces overall impact on instance performance.

 

Building the Complete Workflow

 

A typical extract workflow looks like this: a scheduled trigger fires nightly. A query retrieves a set of records. A Begin File action creates a file record. A loop iterates over each record, appending a row for each record with values extracted and transformed as needed. After the loop completes, Build File generates and attaches the final CSV. From there, you might email the file, attach it to a record, or send it to an external system via REST call.

 

The modular design means you can add conditional logic, only append rows that meet certain criteria, handle errors at the append stage, or skip certain records entirely.

 

Before building the file, you could add validation logic: check that you appended at least one row, verify that the row count matches expected criteria, or confirm that required fields are populated correctly. If validation fails, you can skip the build step and notify an administrator.

 

 

🚀 There are additional actions in this spoke, but they fall outside the scope of this article.

💫 Have you used this feature for something else? Share it in the comments.

 

Version history
Last update:
2 hours ago
Updated by:
Contributors