need hlep in writting data on an excel

priyanka chodip
Tera Contributor

Hi,

My requirement is to create a item, based on what end user has filled in variables. the same data should be written on excel.
it has different sheets, it should fill in the data.

Thankyou,
Priya.

3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@priyanka chodip 

you want to create excel file or you want to create RITM by parsing excel file?

what's your business requirement here?

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

Hi @Ankur Bawiskar 
so the requirement is when user needs a new catalog item basically what the requestor do is take a template and fill in the data and send it for development.
template looks like below

priyankachodip_0-1700477880926.png

from here the requirement starts.
so instead of user picking up the excel and filling the the info we came up with an idea of creating an item and list out the variables
example:
1. under general info label we have variables request item name, business application, description etc... listed in above template
2. and next comes catalog item variables label under that we have variables listed in screenshot.

priyankachodip_1-1700478396572.png

3.the last one is workflow  and below are the variables will be listed under workflow label.

priyankachodip_2-1700478694657.png

so when item gets submitted on RITM we need excel attached with the variable info filled by the user.
example below:

priyankachodip_3-1700479328115.png

so am stuck at writting the info from RITM Variables to excel.
Thankyou
Priyanka




Hi,
I am not sure about the excel file, but a csv file can be generated and can be attached to the RITM using script.

Sample Script:

var grX = new GlideRecord(targetTable);//Whatever your table
  grX.addQuery('sys_id',targetSys_id);//the record's sysid on which you want to add this 
  grX.query();
  if(grX.next())
  {
    var grAttachment = new GlideSysAttachment();
    grAttachment.write(grX, fileName, 'application/csv', csvData);
  }
//Name can be of your choice like fileName=DemoCSVFile
//the data can be like below
//csvData="Name;Address;ID\nSaurabh;India;Ge5363\nWilliam08;Out of India;Ge1234"
//You have to build the csvData Variable as per your need




Thanks and Regards,

Saurabh Gupta