Export JSON From a List
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2024 08:35 PM
Hi,
If i go to the incident list and I personalized the List Columns and stay only with two columns:
short description
assignment group
then I click on Export and choose JSON.
The JSON’s file contains all columns and data and not just the desired two columns.
how can I export to JSON only the two columns?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-02-2024 10:50 PM
When you export a list to JSON in ServiceNow, it includes all fields of the records, not just the visible columns. Unfortunately, the platform doesn’t provide an out-of-the-box way to limit JSON exports to specific columns directly from the UI.
To achieve this, you can use a scripted solution:
Create a Scripted REST API:
Write a Scripted REST API that queries the incident table and specifies only the desired fields (short_description and assignment_group) in the response.Use a GlideRecord Query in a Script:
For example:javascript
var gr = new GlideRecord('incident');
gr.addQuery('active', true); // Optional: Filter criteria
gr.query();
var results = [];
while (gr.next()) {
results.push({ short_description: gr.getValue('short_description'),
assignment_group: gr.getDisplayValue('assignment_group')
});
} gs.print(JSON.stringify(results));
Use a Third-Party Integration:
If scripting isn’t an option, consider exporting to Excel first, then programmatically convert the desired columns to JSON using tools like Python or JavaScript.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-03-2024 03:05 AM
Hi @Alon Grod ,
Please try below steps and it should fulfill your requirement.
1. Create a new view (For example, Test) of the incident form layout keeping only those two desired columns.
2. Edit the SN URL as 'https://<myinstance>.service-now.com/incident_list.do?JSONv2&useUnloadFormat=true&sysparm_view=<NewViewName>'
3. This way it should load the page with incident data in JSON format with only desired two fields for each record as you added in your view.
4. Save the file.
If this address your question, please don't forget to mark this response correct by clicking on Accept as Solution and/or Kudos.
You may mark this helpful as well if it helps you.
Thanks,
Animesh Das
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-10-2024 11:40 PM - edited 01-13-2025 11:30 AM
Hi @Alon Grod ,
If you have got chance to check if your requirement is fulfilled to help close the thread for the community,
Please mark a response correct by clicking on Accept as Solution and/or Kudos. You can mark multiple response correct as well.
You may mark this helpful as well if it helps you.
Thanks,
Animesh Das