Export JSON From a List

Alon Grod
Tera Expert

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?

3 REPLIES 3

yuvarajkate
Giga Guru

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:

  1. 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.

  2. 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.

Animesh Das2
Mega Sage

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

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