Reporting: Limiting Number of Records Shown

RobK_GC
Tera Contributor

I'm trying to create a simple report showing a list of active users that are assigned more than one non-retired, operational PC's from table (cmdb_ci_computer). 

 

Once I configure the report to group by "assigned to", I get a list of Users with each of their assigned PC's nested beneath, as expected. No problem up until this point.

 

Now what I want to do is show ONLY those users with results greater than 1.

Again, I do not want to show users assigned only one PC.

So, I have 2 questions:

 

1. How can I filter the list to only show those users with results greater than 1? 

2. Why is this exact functionality only available at the related list level for the same report?

Why not at the base report level? 

 

RobK_GC_1-1761847941304.png

 

Any assistance is greatly appreciated.

Thanks in advance. 

 

4 REPLIES 4

RobK_GC
Tera Contributor

Hi Syed14,

 

Thank you for the reply, but this did not solve the problem. 

 

I provided a specific use case to preemptively satisfy the question most responders would naturally ask. However, the problem is really as simple as this:  How can I create any simple list report and filter based on the number of records returned in the report? I shouldn't need a script to do this. It should be a simple option. After all, this exact functionality is available (as shown in my original post), but not at the base report level. It's available only as a "Related list Condition", which is not useful. I have no use for a "related list" for a simple list report. 

 

My honest initial assumption was that the functionality i am looking for IS available, I am just ignorant of it. If that's the case, please advise. But from what I can see, if I create a simple list report, there is no option...at the level of [table] Conditions..... to "Show only results that have the selected number of related records".  

Ankur Bawiskar
Tera Patron
Tera Patron

@RobK_GC 

it's not possible with List type report.

Approaches

1) you can try to use Database view by joining sys_user and CI table

OR
2) create scripted filter condition in report

the Script include should be client callable and something like this

function checkRecords(){
	try{
		// your code here

		return array;
	}
	catch(ex){
		gs.info(ex);
	}
}

AnkurBawiskar_0-1761918279657.png

 

How to call it in report condition?

1) create report on your table

2) add the filter condition as this and ensure you return record sysIds

sys_id [IS ONE OF] javascript:checkRecords()

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

Ankur Bawiskar
Tera Patron
Tera Patron

@RobK_GC 

you can try this in reporting, example below enhance for CI table

Table - sys_user

In related list condition select this

Asset -> Assigned to

Greater than 1

AnkurBawiskar_1-1761918417443.png

 

AnkurBawiskar_2-1761918417352.png

 

 

💡 If my response helped, please mark it as correct and close the thread 🔒— this helps future readers find the solution faster! 🙏

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader