Article

Creating a ServiceNow Catalog with Attachment Upload and Auto-Update to a Table

Author: Agus Budi Harto, 2025-10-16 08:50:35

Creating a new catalog item in ServiceNow is relatively straightforward. Thanks to its user-friendly interface and the abundance of online tutorials and documentation, even beginners can get started quickly. However, things get a bit more complex when you're asked to build a catalog item that allows users to upload a spreadsheet attachment and automatically update a specific table—like the hardware asset table.

In this article, I’ll walk you through a practical, experience-based guide to building a ServiceNow catalog item that includes a downloadable template, allows users to upload a completed spreadsheet, and automatically imports the data into the alm_hardware table.

Overview of the Process

To achieve this, we’ll go through the following steps:

  1. Create a Staging Table

  2. Create a Transform Map

  3. Set Up a Data Source

  4. Configure a Scheduled Import

  5. Write a Business Rule

  6. Build the Catalog Item with Attachment Support

Let’s dive into each step using a simple use case: creating a catalog item called "Upload Asset".

1. Creating the Staging Table

The staging table acts as a temporary storage area for the uploaded spreadsheet data before it’s transformed and inserted into the alm_hardware table. To ensure compatibility, the staging table should mirror the structure of the target table.

1.1 Create the Table
  • Navigate to All - System Definition - Tables, then click New.


  • Set the Label to something like Imp Tmpl Alm Hardware. The Name field will auto-populate.

  • For Extends table, select Import Set Row.

  • Click Submit.


1.2 Add Required Fields
  • Add fields to the staging table that match the structure and data types of the alm_hardware table.

  • For example, fields like u_acquisition_method, u_model_id, u_serial_number, etc., should be created to align with the target table.

2. Creating the Transform Map

The transform map defines how data from the staging table is mapped and transferred to the target table.

2.1 Create the Transform Map
  • Go to All - System Import Sets - Administration - Transform Maps, then click New.


  • Set the Name to something like Hardware import.

  • Choose the Source table as your staging table (e.g., u_imp_tmpl_alm_hardware).

  • Set Target table to alm_hardware.

  • Ensure Active and Run business rules are checked.

  • Click Update.


2.2 Map the Fields
  • In the transform map record, scroll down to the Field Maps section and click New.

  • Set the Source field (e.g., u_acquisition_method) and the corresponding Target field (e.g., acquisition_method).

  • Set Choice action to Create and Coalesce to False.

  • Repeat for all necessary fields.


3. Setting Up the Data Source

The data source defines how the uploaded file is retrieved and linked to the import process.

3.1 Create the Data Source
  • Navigate to All - System Import Sets - Administration - Data Sources, then click New.


  • Set the Name to something like Hardware asset data.

  • For Import set table name, select your staging table.

  • Set Type to File, Format to Excel, and File retrieval method to Attachment.

  • Click Update.


3.2 Link the Transform Map
  • In the data source record, scroll to the Related Links section and click Create Transform Map.

  • Select the transform map you created earlier (Hardware import).

4. Configuring the Scheduled Import

Although we’ll trigger the import manually via a business rule, we still need to define a scheduled import.

  • Go to All - System Import Sets - Administration - Scheduled Imports, then click New.


  • Set the Name to Hardware asset data import.

  • Choose the Data source you created earlier.

  • Set Active to False (we’ll trigger it manually).

  • Click Submit.


5. Writing the Business Rule

This business rule will detect when a user submits the catalog item and trigger the import process automatically.

  • Navigate to All - System Definition - Business Rules, then click New.

  • Set the Name to PM - Upload Asset Attachment.

  • Set the Table to sc_req_item, and check Active and Advanced.

  • Under the When to run tab:

    • Set When to async

    • Check Insert

    • Add a filter: Item is Upload Asset

  • Leave the Actions tab empty.

  • In the Advanced tab, paste the following script:

(function executeRule(current, previous /*null when async*/ ) {
    var attachGR = new GlideRecord("sys_attachment");
    attachGR.addQuery("table_name", "ZZ_YY" + current.getTableName());
    attachGR.addQuery("table_sys_id", current.sys_id);
    attachGR.query();
    if (attachGR.next()) {
        attachGR.table_name = current.getTableName();
        attachGR.update();
        GlideSysAttachment.copy('sc_req_item', current.sys_id, 'sys_data_source', '72fcc59d1b1a06507bfd2022f54bcbfc');
    }
    var schImp_GR = new GlideRecord('scheduled_import_set');
    schImp_GR.addQuery('name', 'Hardware asset data import');
    schImp_GR.query();
    if (schImp_GR.next()) {
        SncTriggerSynchronizer.executeNow(schImp_GR);
    }
})(current, previous);

6. Building the Catalog Item with Attachment

Now it’s time to create the actual catalog item that users will interact with.

  • Navigate to Maintain Items and click New.

  • Set the Name to Upload Asset.

  • In the Questions tab:

    • Add a Downloadable Template (e.g., Excel file with required fields).

    • Add an Attachment variable to allow users to upload their completed spreadsheet.

  • Save and publish the catalog item.

Final Thoughts

With these steps, you’ve successfully created a ServiceNow catalog item that allows users to upload a spreadsheet and automatically update the hardware asset table. This approach streamlines asset management and reduces manual data entry errors.

Whether you're building this for internal IT operations or as part of a larger automation initiative, this pattern can be adapted for other tables and use cases across your ServiceNow environment.

LinkedIn

Tags: Opinion Servicenow

478 reviews


Add comment