To Generate a CSV File in the servicenow workflow using the and email it as attachment

Samudra Ghosh1
Tera Expert

Hello,

 

We have important requirement from the client to create a CSV file with catalog variable values and the field values, in workflow or anywhere in the ServiceNow instance. and Email the attachment.

 

Early response will be appreciated.

 

Thanks,

Samudra

1 REPLY 1

Ratnakar7
Mega Sage

Hi @Samudra Ghosh1 ,

 

  1. Create a workflow that includes the necessary activities to gather the catalog variable values and field values that you want to include in the CSV file. You can use activities like Script, Query, or Transform Map to retrieve the data.

  2. Use a Script activity to format the data into CSV format. You can use JavaScript code to loop through the data and concatenate the values with commas to create the CSV rows.

  3. After the data is transformed into CSV format, use a "Script" activity to write the CSV data to a file on the ServiceNow instance. You can use JavaScript code to generate the CSV content and write it to a file. [ you can refer JavaScript create and download CSV file ]

  4. Next, use the "Email" activity to compose an email and attach the generated CSV file. In the email configuration, specify the recipient(s), subject, and body of the email. For the attachment, you can use the file generated in the previous step.

  5. Finally, run the workflow to trigger the generation of the CSV file and sending of the email with the attachment.

 

If my response was helpful in resolving the issue, please consider accepting it as a solution by clicking on the Accept solution button and giving it a thumbs up 👍. This will benefit others who may have a similar question in the future.

 

Thank you!

Ratnakar