Establishing Relation Between Flow Designer, Transform Map, and Target Records

rohanaditya
Tera Contributor

When we import data into ServiceNow, it never goes directly into the target table. The usual process is:

  • Load the file into a staging table

  • Create a Transform Map

  • Run the Transform to move data from the staging table into the target table

Normally, this is done manually using Load Data under System Import Sets. If the dataset is new, we create a new import set table. Otherwise, we use an existing one, upload the file, submit it, then configure the transform maps and run them.

The use case is to automate this entire sequence with Flow Designer.

The requirement was to create multiple Products and their related Sold Products from an attached Excel file to a catalogue request.


Data Source Setup:

  • Type: File

  • Format: Excel

  • Retrieval Method: Attachment

  • Attach the Excel file and test load with sample records

  • Validate the data in the import set table

  • Add a reference field to store the RITM


Flow Designer Automation:

  • For a single product, directly create the record and add its link in RITM comments.

  • For multiple products:

    • Copy the attachment from the RITM to the Data Source

    • Create a new Import Set using GlideImportSetLoader

      • getImportSetGr(): create a new Import Set record

      • loadImportSetTable(): load the data from the Data Source into the staging table

      • Store the RITM number in the import set record

    • Trigger the Transform Map using GlideImportSetTransformerWorker with:

      • Import Set sys_id

      • Transform Map sys_id


Transform Map Setup:

  • Source Table: Import Set table (u_create_multiple_products)

  • Target Table: cmdb_model

  • Field Maps:

    • Name

    • CD Number

    • Category

    • Comments (to capture RITM details)


Transform Scripts:

  • onAfter: After each Product is created, automatically create related Sold Products.

  • onComplete: After all Products and Sold Products are created, generate clickable links and add them as a comment on the RITM.


Final Flow Steps:

  • Fetch the Data Source record

  • Delete the attachment from the Data Source (cleanup)

  • Update the RITM and REQ with the created records


With this approach, the manual load → transform → create records workflow is fully automated inside Flow Designer, while still using ServiceNow’s GlideImportSetLoader and GlideImportSetTransformerWorker under the hood. This makes it possible to handle Excel imports, generate related records, and maintain traceability back to the catalog request seamlessly.


Full Blog Reference

I have detailed the full walkthrough with screenshots and code here:
https://aytid.github.io/servicenow/productCreation.html

 

0 REPLIES 0