How to get the Sys id after creating a record via script

shaik_irfan
Tera Guru

 

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 ?

1 ACCEPTED SOLUTION

sachin_namjoshi
Kilo Patron
Kilo Patron

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);

View solution in original post

5 REPLIES 5

Minarath Tep
Tera Contributor

Mine doesn't work. I do it in Script Include. it returns null.
Is there anyone have any other solutions?