How to import records into the sc_req_item table using an Excel file and the ServiceCatalog API?

Smith Johnson
Kilo Sage

Hello,

I have the following requirement that I am trying to implement.

1. I have created a simple catalog item that looks like this:

SmithJohnson_1-1778848279103.png

Variables:
Requested for (requested_for)
Request summary (request_summary)

Detailed description (detailed_description)

2. I have an Excel file where each row represents a distinct requested item. Three columns in the file store the values for each of the variables defined in the catalog item above (see Step 1).

SmithJohnson_2-1778848302008.png

 

Requirement: I want to implement a logic where an Excel file is imported, and RITMs are automatically created. Each row in the Excel file represents one RITM. The values in the row’s columns should be mapped to the corresponding variables of the catalog item.

For example, when the first row of the Excel file is imported, it should result in the creation of a RITM (e.g. RITMXXXXXX) with the following variable values:

  • Requested for: Abel Tuter
  • Request summary: First request
  • Detailed description: This is a dummy first request

3. I created a data source, like the following:

SmithJohnson_3-1778848327923.png


4. Then, I created a transform map, as shown below. 

SmithJohnson_0-1778848267262.png

 


But starting from here, I am confused. I put as target the sc_request table, but not sure if this is correct.


What the target table should be?
How can I invoke the ServiceCatalog API, Order Now, for each of the rows?

Thank you in advance,
Smith.

11 REPLIES 11

@Smith Johnson 

Just a quick follow-up—were you able to review the links above and try the suggested approach?
Please let me know if you need any assistance.

Regards,
Ankur
Certified Technical Architect  ||  10x ServiceNow MVP  ||  ServiceNow Community Leader

Tanushree Maiti
Tera Patron

Hi @Smith Johnson 

 

Using following steps, you can create bulk catalog item requests in ServiceNow using an Excel file. 

 

Option 1: Using Data Source ,Transform map script(onBefore) .

                 Refer: Create a RITM From transform map scripting 

 

Step 1: Create the Excel File

Prepare an Excel spreadsheet with columns that match the catalog item fields below:

  • Requested for (Reference)
  • Request Summary (Single Line Text)
  • Detailed Description (Multi Line Text)

 

Example format:

Requested_for

Request Summary

Detailed Description

user1

Sample summary

Sample description

user2

Another summary

Another description

 

Step 2: Import the Excel File into ServiceNow

  1. Sign in to ServiceNow with the appropriate access rights.
  2. Navigate to System Import Sets → Load Data.
  3. Click New to create a new data source.
  4. Set the Type field to File.
  5. Upload the Excel spreadsheet.
  6. Complete any additional required fields and save the record.
  7. After saving, select Load All Records to import the spreadsheet data into the import set table.

 

Step 3: Transform the Imported Data into the Target Table

  1. Navigate to System Import Sets → Administration → Transform Maps.
  2. Click New to create a transform map.
  3. Choose the import set table as the Source Table.
  4. Select the destination table, typically sc_req_item or the relevant catalog item table, as the Target Table.
  5. Add an onBefore Script: Use the following code template in the Transform Scripts related list. 
(function runTransformScript(source, map, log, target /*undefined onStart*/ ) {
 
    var cartId = GlideGuid.generate(null); 
    var cart = new Cart(cartId);
    var item = cart.addItem('<YOUR_CATALOG_ITEM_SYS_ID>'); 
 
    cart.setVariable(item, 'requested_for', source.requested_for);
    cart.setVariable(item, 'short_description', source.requested_summary);
cart.setVariable(item, 'description', source.detailed_description);
    var rc = cart.placeOrder(); 
    ignore = true; // Prevents the transform map from creating a duplicate record
 
})(source, map, log, target);
 

Step 4: Validate the Imported Records

  1. Open the target table (for example, sc_req_item).
  2. Review the newly created records.
  3. Confirm that all field values have been imported correctly.

 

(Optional)

Step 5: Automate the Import Process

For recurring imports, you can configure automation:

  1. Go to System Import Sets → Administration → Scheduled Data Import.
  2. Create a scheduled import job.
  3. Select the appropriate data source.
  4. Define the execution schedule based on your requirements.

 

Option 2: it is using data source, transform map & BR

                              Automate Data import from Excel File Attachment via Catalog item & Import Sets

 

 

Please Accept the solution if it assisted you with your question & Mark this response as Helpful.
Regards
Tanushree Maiti
ServiceNow Technical Architect
LinkedIn: https://www.linkedin.com/in/tanushreemaiti