How to get a URL link of the record list in ServiceNow?

Community Alums
Not applicable

Hi ,

i'm able to get the URL of user in following way in background script

======================================

var gr = new GlideRecord('sys_user');
gr.get(gs.getUserID());

 

var url = gs.getProperty('glide.servlet.uri') + gr.getLink(false);
gs.info(url);

===========================================

output:-

https://dev100338.service-now.com/sys_user.do?sys_id=6816f79cc0a8016401c5a33be04be441&sysparm_stack=sys_user_list.do?sysparm_query=active=true

======================================================================

In a similar way,i need to GlideRecord "incident" table and sort the records which is assigned to network team and get list URL of all records assigned to that team.

var gr = new GlideRecord('incident');
gr. addEncodedQuery('assignment_group=287ebd7da9fe198100f92cc8d1d2154e') ;

gr.query();

var url = gs.getProperty('glide.servlet.uri') + gr.getLink(false);
gs.info(url);

output:here i'm not getting the link of records list view 😕

 

 

1 ACCEPTED SOLUTION

Hi,

yes do this

var url = gs.getProperty('glide.servlet.uri') + '/nav_to.do?uri=' + 'incident' + '_list.do?sysparm_query=' + 'assignment_group=287ebd7da9fe198100f92cc8d1d2154e' + '&sysparm_order=sys_created_on&sysparm_order_direction=desc';

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

12 REPLIES 12

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

use this

var gr = new GlideRecord('incident');

gr. addEncodedQuery('assignment_group=287ebd7da9fe198100f92cc8d1d2154e') ;

gr.query();

while(gr.next()){

var url = gs.getProperty('glide.servlet.uri') + gr.getLink(false);

gs.info(url);

}

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

@Akash 

Hope you are doing good.

Did my reply answer your question?

If so, please mark appropriate response as correct & helpful so that the question will appear as resolved for others who may have a similar question in the future.

Thanks!
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Community Alums
Not applicable

Hi Ankur,

this will generate individual URL's of records..I need single URL of complete records assigned to particular team. 

Hi,

then do this

	var url = gs.getProperty('glide.servlet.uri') + '/nav_to.do?uri=' + 'incident' + '_list.do?sysparm_query=' + 'assignment_group=287ebd7da9fe198100f92cc8d1d2154e'; 
	gs.print(url);  

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader