- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 08:25 AM
Hi,
On the Service portal once user clicks the button i am getting all the details from the html using input method and i am able to create a record with below script
var gr = new GlideRecord('u_qa');
gr.initialize();
gr.question = input.u_questions;
gr.name = input.name;
gr.insert();
this goes and create a record u_qa table but i want the sys id of the created of record as a response. can anyone please help me how to do that ?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 08:26 AM
use below
var gr = new GlideRecord('u_qa');
gr.initialize();
gr.question = input.u_questions;
gr.name = input.name;
var s = gr.insert();
gs.info(s);

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 08:26 AM
use below
var gr = new GlideRecord('u_qa');
gr.initialize();
gr.question = input.u_questions;
gr.name = input.name;
var s = gr.insert();
gs.info(s);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-01-2022 05:05 AM
"very very" thank you so much... i spent time trying other way, but its help me

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 08:27 AM
If you store the value of .insert to a variable you can use it.
See below script
var gr = new GlideRecord('u_qa');
gr.initialize();
gr.question = input.u_questions;
gr.name = input.name;
var sys_id = gr.insert();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-03-2020 08:31 AM
You can get the sys_id of the record by storing it in variable
you can then re-use it
var gr = new GlideRecord('u_qa');
gr.initialize();
gr.question = input.u_questions;
gr.name = input.name;
var sysId = gr.insert();
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader