Database view

priyanka1028
Tera Contributor

Hi Team,

 

I want to show the RITMs which are in open, pending and work-in-progress state but their related SC Tasks and Change Tasks both are closed using database view.

Please help me with this requirement.

8 REPLIES 8

It's documented here Add a table to the database view (servicenow.com) - 

 

To add an OR to your Where clause, use ||.
For example, to query all incidents related to RFCs OR all incidents that are the parent of a change request, use the syntax: inc_rfc = chg_sys_id || chg_parent = inc_sys_id.

You can do multiple condition using &&.
For example, 'screq_active = 1 && another_condition = true'
You can also add additional condition on the where clause of each table you join.

Pavankumar_1
Mega Patron

Hi @priyanka1028 ,

1.  You can refer below picture and create database as below and add your conditions.

Screenshot 2024-04-29 at 4.54.53 PM.png

2. where clause on sc_task table record (sctask_request_item=ritm_sys_id) && (ritm_state='1' || ritm_state='2') && (sctask_state='3') . Refer below

Info: state 1 is for open , 2 is for work in progress, 3 is for closed complete

Screenshot 2024-04-29 at 4.58.13 PM.png

If it helps please click Accept as Solution/hit the Thumb Icon.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar

Murthy Ch
Giga Sage

Hello @priyanka1028 

As mentioned by @Pavankumar_1 and @Kieran Anson 

You can create the database view for your scenario.

In addition to it if you want to add the where clause for change_tasks as well:
you just need to create one more record in View tables related list with the below condition:

 

(changetask_parent=ritm_sys_id)&&(changetask_state='3')&&(ritm_state='1' || ritm_state ='2')

 

MurthyCh_0-1714413132838.png

 

 

Thanks,
Murthy