The CreatorCon Call for Content is officially open! Get started here.

Generate a report via script and attach it as a PDF to another record.

Community Alums
Not applicable

Hi All,

I have a custom table, where that custom table stores some information related to users

My requirement is to generate a report from a custom table whenever a record got inserted and attach that report to the respective user's HR profile. 

Is it possible to generate a report via script and attach it back to the record as a PDF. Please advise.

Thank You.


3 REPLIES 3

anshul_goyal
Kilo Sage

Hi @Community Alums,

Please refer to the community post link below for your requirement:
https://www.servicenow.com/community/platform-analytics-forum/create-a-report-using-scripting/m-p/1276725

Please mark my solution as Helpful and Accepted, if it works for you in any way!

Thanks

Community Alums
Not applicable

Hi @anshul_goyal , 

Thank you for the thread. I have looked into it, and yes, we can schedule and send the report via email. However, in my case, how can I attach the report to a particular record?

 

Hi @Manikanta Kota / @Ankur Bawiskar / @Sandeep Rajput Can anyone of you provide some insights on this, that would be more helpful. Thank you in advance.

 

Thank You,

Sirraj

Hi @Community Alums 

you can try doing glide query to Update table_sys_id in the sys_attachment table of your attachment with the sys_id of your record.  sample script : 

var gr = new GlideRecord("sys_attachment");

if(gr.get("report_SYSID"))

{ gr.table_sys_id="record_sys_id";

gr.table_name="<record _table_name>"; // example if the record is on change table use change table name

gr.update();

}

Kindly mark the reply as a correct answer / helpful if it helped to solve your question.

Thanks,
Anwesha