Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

How to create a payload containing all the data of first 10 incidents in an incident list?

nirwan_ritik
Tera Contributor

Hi there community!

I have encountered this question while doing some random chat with my colleagues. How can we create a payload which will have all the data of an incident record in any script?
Kindly help me know whether this is possible and if yes, how 🙂

 

++ is there any OOB functionality in the tool which automatically creates payload of RITMs?

 

Regards,

Ritik

1 ACCEPTED SOLUTION

Martin Grosskop
Tera Guru

Hello Ritik,

 

There is a script include available to convert a GlideRecord into a JSON object:

eg:

 

var current = new GlideRecord('incident');
current.get('a708c99ec3994618c736ca7dc00131ad');


var util = new global.GlideRecordUtil();
var hashmap = {};

util.populateFromGR(hashmap,current)

gs.info(hashmap);

 

 

 

View solution in original post

2 REPLIES 2

Martin Grosskop
Tera Guru

Hello Ritik,

 

There is a script include available to convert a GlideRecord into a JSON object:

eg:

 

var current = new GlideRecord('incident');
current.get('a708c99ec3994618c736ca7dc00131ad');


var util = new global.GlideRecordUtil();
var hashmap = {};

util.populateFromGR(hashmap,current)

gs.info(hashmap);

 

 

 

Et Voila! That worked 🎆
hashmap is storing an object so I updated your script to:
gs.info(JSON.stringify(hashmap));

Thanks for the help 🙂