Exporting unique records in csv

Pravin11
Tera Contributor

Hi,

 

Can someone help to export the list having unique data in the report through UI action.

3 REPLIES 3

sushantmalsure
Mega Sage
Mega Sage

Share details on table name , what do you mean by unique data (like number, short_Desc, or anything)

If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

Pravin11
Tera Contributor

we need to export incident table list and unique data means the column should not have any duplicate values as we are exporting the report through action.setRedirectURL() method.

ChrisBurks
Mega Sage

The following would be a basic example:
How to create a UI Action whether for a list or form can be found here:
https://docs.servicenow.com/bundle/utah-platform-administration/page/administer/list-administration/...

action.setRedirectURL ( 'http://www.mysite.com/mypage.htm' );

 

If you take that concept and combine it with using the URL method of exporting data by CSV including URL parameters to add sysparm_query (basically an encoded query to filter the specific records you want) as well as the sysparm_fields (to identify which fields to include in the export), you should be able to get what you need.

How to construct your URL to be used in the redirect:

https://docs.servicenow.com/bundle/utah-integrate-applications/page/administer/exporting-data/task/t...

 

How to easily construct the encoded query for the sysparm_query parameter:

https://docs.servicenow.com/bundle/utah-platform-administration/page/administer/exporting-data/task/...

 

To get information based on items checked in the list use this reference: (This is client side)

https://developer.servicenow.com/dev.do#!/reference/api/sandiego/client/GlideListClientAPINEx#GLNEx-...

 

Putting it together with a UI action that is configured to be run client side and getting a items checked in a list and exporting a CSV with the checked records and specific fields, the script might look like this:

function getReport(){
	var checkedRecords = g_list.getChecked();
var URL = [
	'/incident_list.do?CSV&sysparm_query=sys_idIN',
	checkedRecords,
	'&sysparm_fields=number,short_description'
].join();
location.href = URL;

}

(keep in mind this is just a rudimentary example to get you started)

UI Action:

ui_action_example.png

 

List View of checked items

list_view.png

 

 

Screenshot of downloaded CSV

result_of_downloaded_csv_file.png