- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2025 06:44 PM
@Asmita7 You can try the following script.
var gr = new GlideRecord('incident');
gr.addQuery('category','software');
gr.query();
var jsonArray = [];
while(gr.next()){
var jsonObj = {};
jsonObj["number"] = gr.getValue('number');
jsonArray.push(jsonObj);
}
gs.info(JSON.stringify(jsonArray));
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2025 12:07 AM
@Asmita7 Is there anything wrong with my answer?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-27-2025 12:45 AM
@Sandeep Rajput ... It's working. Thank you for your time.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-24-2025 08:33 PM
var gr = new GlideRecord('incident');
gr.addQuery('category', 'software');
gr.query();
var incidents = []; // Array to hold incident numbers
while (gr.next()) {
incidents.push(gr.number.toString()); // Add incident number to the array
}
var jsonObject = { incidents: incidents }; // Create JSON object
gs.print(JSON.stringify(jsonObject)); // Print JSON object
This will output a JSON object with all incident numbers.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2025 05:04 AM - edited 01-25-2025 05:07 AM
Hello @Asmita7
var grINC = new GlideRecord('incident');
grINC .addQuery('category', 'software');
grINC .addActiveQuery();
grINC .query();
var incidents = [];
while (grINC .next()) {
incidents.push({
number: grINC .getValue('number'),
caller: grINC .getDisplayValue('caller_id'),
assigned_to: grINC .getDisplayValue('assigned_to')
});
}
var jsonObject = {
incidents: incidents
};
// Convert the JSON object to a string and beautify it
var beautifiedJson = JSON.stringify(jsonObject, null, 4);
gs.print(beautifiedJson);
When above code is run in background script output is as below:
If my response has helped you hit helpful button and if your concern is solved do mark my response as correct.
Thanks & Regards
Viraj Hudlikar.