Attaching a report to an email notification

Jamsta1912
Tera Guru

Hi all,

There's a reference in the docs to attaching reports to email notifications:

https://docs.servicenow.com/bundle/kingston-servicenow-platform/page/administer/notification/concept...

The syntax to use is

${report:X:Y}

I'd assumed this needs to go in an email script, but the script editor doesn't like the syntax. I've tried putting it in the message HTML of the actual notification, but in that case the email fails to send and there is a very meaty error message appearing in the logs that begins:
'For input string: "reportID": java.lang.NumberFormatException: For input string: "reportID": java.lang.NumberFormatException.forInputString(NumberFormatException.java:65) java.lang.Integer.parseInt(Integer.java:580) '...

Does anyone have any thoughts on this?

Jamie

 

8 REPLIES 8

The notification has table = Requested Item (sc_req_item), and it's being triggered by a custom event. I'm working on my PDI which is on Kingston. I'm not sure if any of that is relevant, but it could be!

Jamsta1912
Tera Guru

Ah, something I just realised. As I've pasted ${report:reportID:0ca66956db1c630092211fc7689619c3} into the Message HTML field, it's being HTML-ified, and when I look at the source code it's got a hyperlink embedded. When I remove that, it works!

But - the report is being attached to the outbound email as a PDF, and I would like it to be in Excel format. Any thoughts on that? I can repost as a separate question if necessary, as I realise it's a separate issue.

Jamie.

Jamsta1912
Tera Guru

There's more. This post, which I missed when I searched before posting my original question, has an answer to how to attach as an Excel spreadsheet instead of the default PDF:

https://community.servicenow.com/community?id=community_question&sys_id=e65e8feddb9cdbc01dcaf3231f96...

I've added 'output type' to the string, like this:

${report:reportID:0ca66956db1c630092211fc7689619c3:output_type:.xls}

and this is working. However, I also tried with .xlsx instead of .xls, and that does not work. So we're limited to .xls by this method.

Jamie.

 

siva_
Giga Guru

So lets say i have added this in email script and if my report doesnot have any results filtered in my list report for a particular day, and the records is 0, even an excel with empty rows is being sent out. is there anything that can be done.