Reporting: How to display the last record created

MStritt
Tera Guru

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.

find_real_file.png

 

1 ACCEPTED SOLUTION

 

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'

};

View solution in original post

10 REPLIES 10

barshaNow
Mega Expert

Below thread may help, which would require you to write a script include and call it in the filter condition

https://community.servicenow.com/community?id=community_question&sys_id=c5280f6ddb1cdbc01dcaf3231f96...

Thanks! Unfortunately, I'm not sure how I would need to create the script. New to scripting. This is the table I'm using in the report.

find_real_file.png

 

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'

};

Is 'new jira' the name of the script include?

sys_id = javascript: new jira().runReport() 

 

find_real_file.png

 

find_real_file.png