SysID of a record

asher14
Tera Contributor

Hello,

Im still new in coding and having some trouble. 

I am currently building a display business rule and client script. In the advance tab in the display BR I need to query the gliderecord to get the sysid of the field "other" (which is 'u_category') from another reference table('u_tracked_table')

 

Heres what I have so far but I am blocked:

 

var gr = new GlideRecord('u_tracked_table');

gr.addQuery('sys_id', u_category.sys_id);

gr.query();

8 REPLIES 8

Brad Bowman
Kilo Patron
Kilo Patron

Use current.field_name in Business Rules to get the value of a field on the record being displayed/inserted/updated, so it sounds like you need to use that in your addQuery line, but I'm not following your example to know if that value is the sys_id in the custom table, or if some other field name should be used there.

 

Hello,

thank you for replying with feedback. It is a two part requirement and I want to focus on part 1 first because I believe I can explain a better. 

 

How do i create a gliderecord to the reference table that gets the sys_id of a field on a record. The field name is called Other however in the backend on that table it is name 'u_category'. 

 

It would help if we use standard terminology.  A table has columns/fields.  Each column/field has a name and a label.  The label is irrelevant for scripting purposes.  From your description, it sounds like you have a field named u_category, but it's unclear if this field is on a table named u_tracked_table, or the table that you are triggering the Business Rule on.  It also sounds like u_category may be a reference type field, which references the table named u_tracked_table?  If it is, the value stored in u_category is the sys_id, so if this field is on the Business Rule table, all you need to do is use current.u_category to get the sys_id of the u_category record.

Anurag Tripathi
Mega Patron
Mega Patron

HI,

Based on what i understood

var gr = new GlideRecord('u_tracked_table'); //this is the table you query
gr.addQuery('<name or lable that says other>', 'Other'); //This is like where <name> is Other
gr.query(); 
if(gr.next())
{
//gr.sys_id  This is the sys if of the row ehre <NAme> is other on u_tracked_table table
}
-Anurag