How to add new column in CSV/Excel file in attachment ?

chandan15
Tera Contributor

There are some csv files contains 10k rows are supposed to add manually to the record, but for later operation we have to add one more column to the csv file. 

Is there a way that we can get the file from attachment table and add one more column with header and values and add to the records attachment again .

 

Appreciate the responses.....!

6 REPLIES 6

Ankur Bawiskar
Tera Patron
Tera Patron

@chandan15 

you can use CSVParser API and try to manipulate that csv, add new column and then add data to that column for those rows

CSVParser - Scoped 

OR
Another way is to get file content of that CSV and then manipulate the column

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

@chandan15 

Hope you are doing good.

Did my reply answer your question?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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

Hello @Ankur Bawiskar ,


Thank you for your response.

I noticed that all the code snippets you shared via the link are focused on parsing values from glideSysAttachment. However, my requirement is to add a new column to the attachment CSV file, not just to read values from it.

Could you please clarify which specific line of code will help me add a new column to the CSV attachment?

Thank you for your assistance.

 

Thanks,

Chandan

@chandan15 

since you said you already had csv files and wanted to add new column to it, that's why I shared the approach to parse and then add new column.

it's an easy requirement.

what did you start with and where are you stuck?

If my response helped please mark it correct and close the thread so that it benefits future readers.

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