We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

How to export specific fields from Multiple Child Incidents into a single Excel file?

Not applicable

Hi everyone,
​I’m working on a requirement where I need to generate an Excel file containing data from multiple Child Incidents associated with a parent record.
​Specifically, I need the export to include the following fields from the child records:
​Incident Number
​Short Description
​Subject Person (or 'Requested For' name)
​My Goal:
I want to be able to trigger this export (either via a UI Action or a scheduled process) and ensure it captures the related child incident data accurately, even if the fields are on the User table (like the name of the Subject Person).
​Questions:
​What is the most efficient way to achieve this? (e.g., Export Sets, Data Broker, or a custom Script Include?)
​How can I ensure I am pulling the "Name" string of the Subject Person rather than just the SysID in the Excel output?
​If using a UI Action, is there a way to prompt the download immediately for the user?
​Any scripts, Flow Designer suggestions, or architectural advice would be greatly appreciated!

1 ACCEPTED SOLUTION

@Community Alums 

I think xls is possible but not XLSX

check this link and it has solution for XLS

Exporto MRVS to Excel 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

View solution in original post

6 REPLIES 6

yashkamde
Mega Sage

Hello @Community Alums ,

 

Use this script in UI Action to get the pdf downloaded with the required fields you want :

var v = new sn_pdfgeneratorutils.PDFGenerationAPI();
var html;

var gr = new GlideRecord('incident');
if (gr.get(current.sys_id)) {
    html = 'Short Description : ';
	html = html + gr.short_description.toString();
        //ADD FIELDS WANT TO SHOW ON PDF..
}

var result = v.convertToPDF(html, 'incident', current.sys_id, 'Incident PDF');

if (result.status === 'success' && result.attachment_id) {
    var downloadURL = '/sys_attachment.do?sys_id=' + result.attachment_id;
    var gURL = new GlideURL(downloadURL);
    action.setRedirectURL(gURL);
} else {
    gs.addErrorMessage('PDF generation failed or no attachment ID returned.');
}

 

If my response helped mark as helpful and accept the solution.

Not applicable

my requirement is excel needs to be created.

Ankur Bawiskar
Tera Patron

@Community Alums 

you can't create EXCEL file within ServiceNow as there is no OOTB API/Class for this.

You can create a PDF or CSV file for this

Generating Custom PDFs - using the new PDFGenerationAPI

another method

Generate PDF and attach to the record

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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

@Community Alums 

Hope you are doing good.

Did my reply answer your question?

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

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