Exporting unique records in csv
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 04:35 AM
Hi,
Can someone help to export the list having unique data in the report through UI action.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 04:39 AM
Share details on table name , what do you mean by unique data (like number, short_Desc, or anything)
Regards,Sushant Malsure
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 05:47 AM
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.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-26-2023 06:17 AM
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:
How to easily construct the encoded query for the sysparm_query parameter:
To get information based on items checked in the list use this reference: (This is client side)
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:
List View of checked items
Screenshot of downloaded CSV