- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2019 02:21 PM
I'm trying to run a report off a table, and only want to display the most recent record created. For example below. I see that this report displays 126 records. I want to be able to display/show only the last record created. Or most recent record. What condition/s should I use, to give me the last record created.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2019 03:32 PM
Your Report Filter condition should be
sys_id = javascript: new jira().runReport()
script include code with Client Callable Checkbox checked.
var jira = Class.create();
jira.prototype = {
runReport: function()
{
var gr = new GlideRecord("u_jira_projects");
gr.orderByDesc("sys_created_on");
gr.query();
if (gr.next()) {
return gr.getValue('sys_id');
}
},
type: 'jira'
};
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2019 04:22 PM
new instantiates the class. The name is just "jira". However, that is a pretty nondescript name. I might recommend the name being something like JiraReporting or something like that to make it clear this is supporting reporting for Jira.
Thay being said? What exactly is the use case for this? The function gives you the last records created but wouldn't listen to any additional filters. Pretty specific and not very reusable.
If you added this to your single score, you would get 1. Are you trying to create a list view with just the last record displayed?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2019 04:40 PM
Hi Adam,
I'm creating a dashboard, that is somewhat of a health check of our JIRA Projects, Members and Issues. Keeping track of when the last time a JIRA Project, Issue, Member was created in ServiceNow from our JIRA instance. Most of the reports on the dashboard will be a score. But as you mention, this one will most likely be a list view, that will just show the last record created.
So, in the sys_id value below, 'jira' would be the name of the script include? so, if the name of my script include was Jira Projects, the sys_id value would be 'sys_id = javascript: new Jira Projects().runReport()'
sys_id = javascript: new jira().runReport()
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-12-2019 08:13 AM
You can't have a space in the name as must be valid JavaScript. Try the name JiraProjects.
Generally, we would just sort the report by created date. This seems to be highly restricted. It is your use case, not mine, but I would have some concerns that direction would be very limiting.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-27-2022 11:37 PM
Hi,
I saw this thread and implemented it.
Currently, only the latest one is displayed, but is it possible to report the latest value of each server?
I would be grateful if you could answer here.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-24-2024 11:25 PM
Hi @ayano , Did you manage to achieve this?