Query in Report

devservicenow k
Tera Contributor

i have created a Database View for t
for time card and time worked.
for task and case. it is working .

 

0702c.jpg

 

what changes do i need to do for this?

 

 

1 ACCEPTED SOLUTION

You can always manually filter the List view or Report where the Parent -> State is not one of Closed, Resolved, Cancelled.  To have the Database View ALWAYS exclude these, just create a Business Rule that looks like this:

BradBowman_0-1675793746134.png

Where Table = u_test1 in your case.  The Script on the Advanced tab looks like this:

(function executeRule(current, previous /*null when async*/) {
	current.addEncodedQuery('tt_parent.stateNOT IN3,6,7');
})(current, previous);

 

View solution in original post

5 REPLIES 5

Brad Bowman
Kilo Patron
Kilo Patron

If the view is working with these tables and where clauses as a starting point I would leave those as is - it's sometimes hard enough to get those right without complicating it.  With the initial results, if you can add a filter to the list to only show the records that you want, then you can create a before Query Business Rule using the Database View name as the Table.  The script could be as simple as something like this:

(function executeRule(current, previous /*null when async*/) {
    current.addEncodedQuery('req_sys_idIN1,2,3,4');
})(current, previous);

where you use the DB view variable prefix for the appropriate table in front of the field name.  You can get the encoded query from your filtered list.

@Brad Bowman  Without using Business Rules it is possible?

You can always manually filter the List view or Report where the Parent -> State is not one of Closed, Resolved, Cancelled.  To have the Database View ALWAYS exclude these, just create a Business Rule that looks like this:

BradBowman_0-1675793746134.png

Where Table = u_test1 in your case.  The Script on the Advanced tab looks like this:

(function executeRule(current, previous /*null when async*/) {
	current.addEncodedQuery('tt_parent.stateNOT IN3,6,7');
})(current, previous);

 

@Brad Bowman   According to BR .

The Report is only showing the data if there is task .

I need all the datas...