- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2021 06:29 PM
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
Solved! Go to Solution.
- 4,106 Views

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2021 09:12 PM
"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.
Mark "Helpful" if this answers your question.
Thanks,
Naveen

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2021 09:02 PM
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.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-31-2021 09:12 PM
"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.
Mark "Helpful" if this answers your question.
Thanks,
Naveen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-29-2022 12:58 AM
How does scripted list works in stock header ????