GlideRecord script

akshay_sharma26
Tera Contributor

Hi,

 

how to write Glide Record Query to get sysid of service_offering using assignment_group sysid in service offering table.

I am using this query.

var gr = newGlideRecord('service_offering');

gr.addQuery('assignment_group', agsysid);

gr.setLimit(1);
gr.query();

3 REPLIES 3

SanjivMeher
Kilo Patron
Kilo Patron

I dont see any issue with the script. Just need to use next to get the record. If you are not getting the result, make sure you are using the right field of service offering. There is also a Approval Group and Support Group and has different field name. May need to replace the addQuery with the right field name.

var so_sys_id = '';

var gr = newGlideRecord('service_offering');

gr.addQuery('assignment_group', agsysid);

gr.setLimit(1);
gr.query();

if (gr.next())
so_sys_id = gr.sys_id;

 


Please mark this response as correct or helpful if it assisted you with your question.

Danish Bhairag2
Tera Sage
Tera Sage

Hi @akshay_sharma26 ,

 

Try this

 

var gr = newGlideRecord('service_offering');

gr.addQuery('assignment_group', agsysid);

gr.setLimit(1);

gr.query();

if(fr.next()){

var id = gr.sys_id;

}

 

Thanks,

Danish

 

Jim Coyne
Kilo Patron

What are you trying to do exactly?  And from where (Business Rule, Flow, Workflow, etc...)?  Reason I ask is your example script is filtering on the "Change group [assignment_group]" field AND you just want 1 record returned (setLimit) BUT a group can be assigned to MANY records, so it's hard to tell what record you will get back.

 

Another issue is your "agsysid" JavaScript variable is defined so not where that is or coming from.  And as others have mentioned, you need to use "next" to get to the record.