Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

How to download List view into excel

skylarj
Kilo Contributor

I need help to provide a button on top right corner to download list view as excel.I know i can go with export from list cloumn but i need a button. Thanks

 

 
 
2 REPLIES 2

Sohithanjan G
Kilo Sage

Hi @skylarj 

 

You can create this UI action

SohithanjanG_0-1710664817237.png

function generateExcel()
{

tblName = g_list.getTableName();
selSysIds = g_list.getChecked();
sysIdList = selSysIds.split(',');	

var encodedQuery = 'sys_idIN'+sysIdList; //sys_idIN

g_navigation.open('/' + tblName + '_list.do?EXCEL&sysparm_query='+encodedQuery, '_blank');

}

 

For selected records to download, use sysparm_query. If you need to download all records, dont use sysparm_query

 

🙂

Please mark as Accepted Solution if this solves your query and HIT Helpful if you find my answer helped you. This will help other community mates too..:)

Deepak Shaerma
Kilo Sage
Kilo Sage

Hi @skylarj 

### UI Action for Export to Excel

You can create a UI Action that instructs users on how to export the list to Excel using the platform’s built-in functionality. This approach ensures adherence to ServiceNow’s security and export mechanisms.

1. Navigate to System UI > UI Actions.
2. Click New to create a new UI action.
3. Fill in the fields on the form:

Name: Give a descriptive name, such as “Export to Excel Guide”.
Table: Choose the incident table.
Action name: This is auto-populated based on the Name but can be adjusted as needed.
Client: Select this option as the action will be executed on the client side.
List: Check this to ensure the action appears in list views.
Form: Optionally check this if you want it available in form views.
Comments: You can provide a description or guidance here.

4. In the Script field, instead of trying to directly execute an export (which isn’t recommended or straightforward due to security reasons), you’d provide a script that either:
- Informs the user to use the built-in export functionality.
- Triggers a modal or an informational alert to guide them.

Example informational script (Client-side):

 

new GwtMessage().notify(‘Use the built-in “Export” option by right-clicking on the list header and selecting “Export > Excel”.’, ‘info’, 5000);

 

5. Conditions: Set conditions for when this UI Action should be available, if necessary.

Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help us a lot.
Thanks & Regards 
Deepak Sharma