The CreatorCon Call for Content is officially open! Get started here.

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

Mahesh Kumar3
Giga Guru

Hi Akash,

You are missing a loop where you will gent Link for every record.

Typically like after gr.query(); you must put:

while(gr.next()){

// then your code.

}

 

so you can iterate over each record and get the value.

 

Regards,

Mahesh Kumar

Community Alums
Not applicable

Hi, 

i don't need individual records but single URL containing all record list of assigned to respective team 

Use the below code:

var groupSysId = 'put sys id here';
var url = gs.getProperty('glide.servlet.uri');
gs.info(url+'incident_list.do?sysparm_query=active=true^assignment_group='+groupSysId);

// put the group sys id accordingly.
// this url will opoen list of active incident of a particular group
//keep changing the group sys ids and get the URLs