Find your people. Pick a challenge. Ship something real. The CreatorCon Hackathon is coming to the Community Pavilion for one epic night. Every skill level, every role welcome. Join us on May 5th and learn more here.

Database View Where Clause Confusion

brandon_chamber
Kilo Contributor

Hello,

I'm trying to setup a very basic database view of the Service Catalog table (sc_cat_item). However, I'd like the view to contain only active items. When I try to setup the view, add the view table and setup a Where clause (cat_active = true), the resulting view returns all records in the table. Why is this? This seems like a simple enough "filter" clause....


Thanks,

Brandon

18 REPLIES 18

Hi Brandon,



It sounds disappointing....



So I had done some workaround regarding it.



Thanks a lot!


Hello Rodrigo,



I am also facing the same issue with where clause operators are not working. what is the workaround you did to make this working. Meanwhile, going to open a hi ticket with SN.



Thanks


Kumar


One option is to create a "Before Query" Business Rule on the database view.



It would look something like this:



Table: Your Database View Name


When: before


Query: checked



Script:


current.addQuery("field", "value");


current.addQuery("field2", "value2"); // repeat for as many conditions as you wish to add


...etc.



This will add whatever queries you specify as the effective "WHERE" clause.


Thanks Josh. I like this workaround.


Hi Kumar,



My workaround was not better then Josh ´s one. I had created two different views joining with the sys_class_name field, which were working for my case. But this idea from Josh is better and more flexible to do whatever you want as a filter.



Thanks Josh;Josh Nerius!