How to get sys_id of a record obtained from gliderecord query.

Karan31
Tera Contributor

Hi , I am creating a UI action to redirect to a record that is queried from another table.

 

1.var itemID = current.sys_id;  >>>>  sys_id of record in Catalog Item table
2.var ts = GlideRecord('sys_atf_test_suite');  >>>> gliderecord on suite table to find a record which has sys_id of catalog item 
3.ts.addQuery('u_suite_id',itemID); >>> quering the table for item sys id in field Suite id
4.ts.query();
5.while(ts.next()){
6.action.setRedirectURL('sys_atf_test_suite.do?sys_id=' + current.sysid); }  >>> as i want to redirect to that record found from quering.

 

1 ACCEPTED SOLUTION

Harsh Vardhan
Giga Patron

updated code

 

var itemID = current.sys_id;

var ts = new GlideRecord('sys_atf_test_suite'); 

ts.get('u_suite_id',itemID);

action.setRedirectURL('sys_atf_test_suite.do?sys_id=' + ts.sys_id); 

View solution in original post

8 REPLIES 8

Harsh Vardhan
Giga Patron

can you confirm , you want to redirect it to the glide record query ts.sys_id page ? if yes then use ts.sys_id

 

1.var itemID = current.sys_id;  >>>>  sys_id of record in Catalog Item table
2.var ts = new GlideRecord('sys_atf_test_suite');  >>>> gliderecord on suite table to find a record which has sys_id of catalog item 
3.ts.addQuery('u_suite_id',itemID); >>> quering the table for item sys id in field Suite id
4.ts.query();
5.while(ts.next()){
6.action.setRedirectURL('sys_atf_test_suite.do?sys_id=' + ts.sys_id); }  >>> as i want to redirect to that record found from

 

 

Harsh Vardhan
Giga Patron

updated code

 

var itemID = current.sys_id;

var ts = new GlideRecord('sys_atf_test_suite'); 

ts.get('u_suite_id',itemID);

action.setRedirectURL('sys_atf_test_suite.do?sys_id=' + ts.sys_id); 

Hi Harsh,

Thanks for the quick reply,

when i am clicking the button i am not redirecting to Suite Record , its going back to Item record

can you add log here . let me know what are you getting in log 

 

var itemID = current.sys_id;

var ts = new GlideRecord('sys_atf_test_suite'); 

ts.get('u_suite_id',itemID);

gs.log('sys id is '+ ts.sys_id);

action.setRedirectURL('sys_atf_test_suite.do?sys_id=' + ts.sys_id);