Scripted Lists in Menu Items

Roberto Cortina
Tera Contributor

Hi everyone,

I'm trying to create a Scripted List for my menu in Service Portal but I can't find any documentation/tutorial about how to create one. Do you know where can I get more information about Scripted Lists?

Regards

1 ACCEPTED SOLUTION

Naveen Velagapu
Mega Guru

"data" object is accessible in the script field. You need declare data.items array and push objects that you need to display as menu items.

Please find below sample code

data.items=[]; // Array to be displayed when clicked on menu
data.count=0; // Indicates number of records

var incGr = new GlideRecord('incident');
incGr.setLimit(5);
incGr.query();
while(incGr.next()){
var obj={};
  obj.title=incGr.getValue('number');
  obj.type='link';
  obj.href='/sp?id=form&table=incident&sys_id='+incGr.getUniqueValue();
  data.items.push(obj);
  data.count++;

}

 

Don't miss to increment data.count as the visibility of menu item will be controlled by data.count.

Output of above code.

find_real_file.png

 

 

 

 

Mark "Helpful" if this answers your question.

 

Thanks,

Naveen

View solution in original post

3 REPLIES 3

Bhawanjit Sing2
Mega Guru

Try checking Adding System Status Scripted List with Numbers to Service Portal – ServiceNow Interests

Also it's better if you check the OOB Scripted List menus. You can get some idea.

Naveen Velagapu
Mega Guru

"data" object is accessible in the script field. You need declare data.items array and push objects that you need to display as menu items.

Please find below sample code

data.items=[]; // Array to be displayed when clicked on menu
data.count=0; // Indicates number of records

var incGr = new GlideRecord('incident');
incGr.setLimit(5);
incGr.query();
while(incGr.next()){
var obj={};
  obj.title=incGr.getValue('number');
  obj.type='link';
  obj.href='/sp?id=form&table=incident&sys_id='+incGr.getUniqueValue();
  data.items.push(obj);
  data.count++;

}

 

Don't miss to increment data.count as the visibility of menu item will be controlled by data.count.

Output of above code.

find_real_file.png

 

 

 

 

Mark "Helpful" if this answers your question.

 

Thanks,

Naveen

Prabeen Raj _ S
Tera Contributor

How does scripted list works in stock header ????