The easy way to encode JSON GlideRecord

Trung
Kilo Guru

Hi all

I sure that you see some troubleshooting when you find a way to encode GlideRecord to JSON string

And I have the easy way to do it with OOTB script include

 

var util= new global.GlideRecordUtil();
var grinc= new GlideRecord("incident");
grinc.get("your_sys_id");
var hashmap={};
util.populateFromGR(hashmap,grinc);//use this function to populate all fields to object hashmap and after that we will encode the hashmap object
gs.print(JSON.stringify(hashmap));
3 REPLIES 3

Ankur Bawiskar
Tera Patron
Tera Patron

@Trung 

Is this a question or you are willing to share some content in community?

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

hi @Ankur Bawiskar 

I just share the content to community to people.

Well before the new UI community I can create a article but now I cannot create article so go to this and post it

Thanks for sharing!

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande