Auto populate catalog item variables with excel import (portal)

Marcel Hartmann
Tera Contributor

Hi all!

 

I try to auto populate catalog item variables (in portal) with an excel import. The reason is that I end up with almost 50 variables in the catalog item. To simplify things, I created an item with 3 variables in my PDI. I am trying to add an 'import from excel' button in the portal to load all the variables for the catalog item from the excel. As an example, I have chosen the following variables: Name (Reference), Group (Select Box) and Additional Information (Multi Line Text).

 

Excel:

 

Macky08_0-1684493958450.png

 

 

 

Does anyone have an idea/approach for implementing my example?

1 ACCEPTED SOLUTION

Hi @Marcel Hartmann ,

Hope you are doing great.

if you want to update the excel files received in email as attachement with catalog item variable , You can achieve this with inbound email action using email parser API. 

 

  1. Create a catalog item in ServiceNow that includes the desired variable fields to capture the information from the Excel file.

  2. Ensure that the catalog item has the 'Import via Excel' button enabled, allowing for Excel file import.

  3. Configure the Email Inbound Action:

    • Set up an email inbound action to process incoming emails with Excel file attachments.
    • Configure the email inbound action to create a request for the desired catalog item when an email with an Excel attachment is received.
    • Extract the necessary information from the Excel file to populate the variable fields of the catalog item.
  4. Extract Data from Excel File:

    • Utilize ServiceNow's Excel Parser API or similar libraries to extract data from the Excel file in the email attachment.
    • Parse the Excel file and retrieve the required information from the appropriate columns and rows.
    • Map the extracted data to the corresponding variable fields of the catalog item.
  5. Create Request and Populate Variables.

// Parse the Excel file and extract data
var excelData = ExcelParser.parseExcel(fileAttachment);
var columnAData = excelData.getColumn('A');
var columnBData = excelData.getColumn('B');

// Create a request for the catalog item
var request = new GlideRecord('sc_request');
request.initialize();
request.cat_item = 'YOUR_CATALOG_ITEM_ID';
request.insert();

// Populate the variable fields with extracted data
request.variables.variable1 = columnAData[0];
request.variables.variable2 = columnBData[0];
// Set values for additional variable fields as needed

request.update();
Please mark the appropriate response as correct answer and helpful, This may help other community users to follow correct solution.
Regards,
Riya Verma

View solution in original post

5 REPLIES 5

msowmiya
Tera Contributor

Hello Marcel,

 

I have a similar requirement. Do you have any solution for this excel import? 

Please share some insights from your analysis.

 

Thanks,

Sowmiya M