database view where clause

Wendy20
Tera Expert

Hi all,

I have created a database view where I need to combine security incidents opened by "x user". and the sys_user table.  I need some help with the where clause to connect the tables and show the user's details based on Security incidents opened by  "x user".  Any help is appreciated.  

 

Wendy20_0-1676078266778.png

 

1 ACCEPTED SOLUTION

Hello @Wendy20 ,

I misread your comment, I thought you want all incidents for which Assigned To is Beth Anglin. However, if you want to get incidents opened by Beth Anglin you can use below mentioned WHERE clause and that will work for you:
Incident --> Order: 100 --> inc_opened_by="46d44a23a9fe19810012d100cca80666"   
User -- Order: 200 --> inc_assigned_to=usr_sys_id

 

Shubham_Shinde_0-1676436178673.png

 

If my answer has helped with your question, please mark it as correct and give it a thumbs up!

 

Regards,

Shubham 

View solution in original post

7 REPLIES 7

Shubham_Shinde
Giga Guru

Hi @Wendy20 ,

You can write a where clause for "sys_user" table mentioning from which field on Security Incident do you want to map the user. (In your case it is assigned_to)
Please refer below example: (I have used Incident table for example, you can replace the same with Security Incident)

Shubham_Shinde_0-1676090542635.png


You can then add all required User fields on database view by editing List Layout. 

If my answer has helped with your question, please mark it as helpful and give it a thumbs up!

Regards,

Shubham



Hi Shubham,

Thank you for this suggestion. It worked for me. I was wondering is there a way to filter to show only incidents opened by 1 user. ie. how to see only the incidents opened by "Beth Anglin" in this database view? 

 

Hello @Wendy20 ,

Glad that it helped you. Yes, there's a way to achieve that, you can make some slight changes in your Database View like below and it should work:
Move the sys_user table to first row by changing it's order and then query it with the sys_id of the user "Beth Anglin".

Shubham_Shinde_0-1676309742375.png

You can also query the user table with user_id instead of sys_id by using usr_user_name="beth.anglin".


If my answer has helped with your question, please mark it as correct and give it a thumbs up!

Regards,

Shubham

Wendy20_0-1676402091368.png

I tried this but when I added the where clause on user sys id and tried I was unable to see any records.  Any advice?  Thank you!