Data generator
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-22-2023 01:04 PM
Hello, for testing purpose I need to create a class which will generates incidents. Parameters: amount of incidents, data captured from already existing incidents, groups and users.
Thanks for help guys M.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
04-04-2023 04:08 AM
Hey, i totally agree with you the best is get more information in order to help the users.
i started to use GPT to help me answering some question and off course i tested and tried before share the information, during the process i got some wrong scripts and invalid information generate from GPT.
And about the signature, i really liked your signature very clear and objective so i apologize for use without give the credits or ask for permission.
However i used GPT to generate a new signature from yours.
If my response was helpful and/or provided a solution, please consider marking it as such. Thank you!
*GPT helped me generate that answer.
So i believe GPT could be very usefully for everyone to get some assistance on very simple requests, like create a glide record to retrieve incidents, when u use GPT for more complex things you need to know very well how to validate the information before use or say something.
Off course, my answer looks like something very complex i agree, let me try to fix and give another suggestion without GPT:
Question:
create a class which will generates incidents
Parameters: amount of incidents, data captured from already existing incidents, groups and users.
In that example i didnt create the class, just a script to run on background script for test proposes, and also generate a log to check the records created;
Background script:
var amount_incidents = 2
var dataFromIncidents = []; //Log Propouses
//glideRecord to retrieve data from existing incidents
var gr = new GlideRecord("incident");
gr.addEncodedQuery("state=2^assignment_groupISNOTEMPTY^caller_idISNOTEMPTY")
gr.setLimit(amount_incidents);
gr.query()
while(gr.next()){
var gInsert = new GlideRecord("incident");
gInsert.initialize()
gInsert.short_description = gr.getValue("short_description");
gInsert.caller_id = gr.getValue("caller_id");
gInsert.category = gr.getValue("category");
gInsert.impact = gr.getValue("impact");
gInsert.urgency = gr.getValue("urgency");
//save the data on array
dataFromIncidents.push({
"sys_id" : gInsert.insert(), //save sysId log propouses
"short_description" : gr.getValue("short_description"),
"caller_id" :gr.getValue("caller_id"),
"category" : gr.getValue("category"),
"impact" : gr.getValue("impact"),
"urgency" : gr.getValue("urgency")
//y....
})
}
//display all incidents created
gs.log(JSON.stringify(dataFromIncidents,2,2));
Thank you for your feedback @Allen Andreas i will try to improve my answer being more human like, i think my answer is very simple and clean compared with GPT.